capture log close
clear
capture program drop _all
set more off
timer clear 1
timer on 1
set seed 123

**************** 
***  PATHS   ***  
****************
*BCCR: 1 if at Central Bank
global BCCR=1
if $BCCR == 1 {
	global path "Y:/Projects/MNC_Suppliers/Suppliers_Alfaro-Urena_Manelici_Vasquez"
}

if $BCCR == 0 {
	global path "~/Documents/GitHub/Suppliers_Alfaro-Urena_Manelici_Vasquez"
}
cd $path 

*log file
local logfile "${path0}/log_files/9-appendix_f"
set linesize 255
log using `logfile', replace
set linesize 255

/*
RESULTS IN APPENDIX F OF THE PAPER (SURVEYS)
*/

********************** 
***  INPUT FILES   ***  
**********************
global survey_proco ""raw_data/survey_proco.dta""
global events_dom ""raw_data/survey_events_dom.dta""
global events_MNC  ""raw_data/survey_events_MNC.dta""
global firms_surveyed ""raw_data/survey_with_corresp.dta""
global mnc_info ""raw_data/survey_mnc_info.dta""
global dom_info ""raw_data/survey_dom_info.dta""
global sellers ""raw_data/survey_proco_seller.dta""
global answers_dom ""raw_data/survey_answers_dom.dta""
global answers_mnc ""raw_data/survey_answers_mnc.dta""
**
** PROGRAM TO GENERATE DIFF IN MEANS
**
 program myttests, eclass
     syntax varlist [if] [in], by(varname) [ * ]
     marksample touse
     markout `touse' `by'
	 local varia_program "mu_1 mu_2 n_1 n_2 mu_1_se mu_2_se d d_se d_t d_p"
     tempname `varia_program'
      foreach var of local varlist {
         qui ttest `var' if `touse', by(`by') `options'
         mat `mu_1' = nullmat(`mu_1'), r(mu_1)
         mat `mu_2' = nullmat(`mu_2'), r(mu_2)
         mat `n_1' = nullmat(`n_1'), r(N_1)
         mat `n_2' = nullmat(`n_2'), r(N_2)		 
         mat `mu_1_se' = nullmat(`mu_1_se'), r(sd_1)
         mat `mu_2_se' = nullmat(`mu_2_se'), r(sd_2)		 
         mat `d'    = nullmat(`d'   ), r(mu_1)-r(mu_2)
         mat `d_se' = nullmat(`d_se'), r(se)
         mat `d_t'  = nullmat(`d_t' ), r(t)
         mat `d_p'  = nullmat(`d_p' ), r(p)
     }
         foreach mat in `varia_program' {
         mat coln ``mat'' = `varlist'
     }
     tempname b V
     mat `b' = `mu_1'*0
     mat `V' = `b''*`b'
     eret post `b' `V'
     eret local cmd "myttests"
     foreach mat in `varia_program' {
        eret mat `mat' = ``mat''
    }
 end

********************************************************************************
************** ONLINE APPENDIX F: TABLES AND FIGURES ***************************
********************************************************************************
 
** Supplementary Figure F1 is a collage of four photographs taken by the authors during survey visits to four domestic suppliers to MNCs
** Supplementary Table F1 is created manually. Summary of number of survey responses
** Supplementary Table F2 is created manually. Summary of the survey response rates by firm type, as a percentage of either the relevant number of firms or events, and with respect to three firms/events sample

********************************************************************************
** Supplementary Table F3
** Comparison: Surveyed vs Not Surveyed Domestic 
********************************************************************************

quiet{
*FIRMS SURVEYED
use $firms_surveyed, clear
keep if tipo=="domestic"
keep cedula_revec surv_cedula nombre1 institucion_contacto Version
rename cedula_revec supplier_ID
rename nombre1 name_survey
rename institucion contact
rename Version version
tempfile domestic_surveyed
save    `domestic_surveyed', replace

use $events_dom , clear
quietly bys supplier_ID: gen dup=cond(_N==1,0,_n)
drop if dup>1
keep supplier_ID

tempfile distinctDOMeconomywide
save    `distinctDOMeconomywide'

use $survey_proco, clear
ren ID supplier_ID

quietly bys supplier_ID: gen dup=cond(_N==1,0,_n)
drop if dup>1
keep supplier_ID

append using `distinctDOMeconomywide'
quietly bys supplier_ID: gen dup=cond(_N==1,0,_n)
drop if dup>1
keep supplier_ID

merge 1:1 supplier_ID using `domestic_surveyed'

gen surveyed=0
replace surveyed=1 if _m!=1

keep supplier_ID surveyed

tempfile domtargetedsurveyed
save    `domtargetedsurveyed'

**** Now adding the information

use $dom_info , clear
keep if event!=.

gen vaperworker=va*1000/(trabaj*500)

keep if year==2009

tempfile infodomevented
save    `infodomevented'

use $sellers , clear

gen vaperworker=va*1000/(trabaj*500)

keep if year==2009
tempfile beforeinfodomproc
save    `beforeinfodomproc'

use $survey_proco, replace
quietly bys ID: gen dup=cond(_N==1,0,_n)
drop if dup>1
keep ID

merge 1:1 ID using `beforeinfodomproc'
keep if _m==3
drop _m

append using `infodomevented'
quietly bys ID: gen dup=cond(_N==1,0,_n)
drop if dup>1
drop dup
ren ID supplier_ID

merge 1:1 supplier_ID using `domtargetedsurveyed'
keep if _m==3
drop _m

replace trabaj_     = trabaj      
replace ingresosir_ = ingresosir_ /500

label variable trabaj_ "Number of Workers"
label variable ingresosir_ "Total Sales"
label variable vaperworker "Value Added Per Worker"

eststo clear
gen notsurveyed=1-surveyed
myttests trabaj ingresos vaperworker, by(notsurveyed) 
}
display "Supplementary Table F3"
esttab, nomtitle nonumbers  ///
    cells("mu_1(fmt(a3)) mu_2 d(star pvalue(d_p))" "mu_1_se(par fmt(2)) mu_2_se(par fmt(2)) d_se(par fmt(2))" ) mlabel("Surveyed" "Not surveyed" "Difference") alignment(c) label collabels(none) 

********************************************************************************
** Supplementary Table F4
** Comparison: Surveyed vs Not Surveyed MNCs 
********************************************************************************

quiet{
*FIRMS SURVEYED
use $firms_surveyed, clear
keep if tipo=="MNC"
keep cedula_revec surv_cedula nombre1 institucion_contacto Version
rename cedula_revec MNC_ID
rename nombre1 name_survey
rename institucion contact
rename Version version
tempfile mncs_surveyed
save    `mncs_surveyed', replace

*****Checking how many distinct events 
use $events_MNC, clear
merge m:1 MNC_ID using `mncs_surveyed'
keep if _m==3
keep MNC_ID seller_*
reshape long seller_, i(MNC_ID) j(nr)
drop if seller_==""
ren seller_ supplier_ID
keep supplier_ID
tempfile economymnc
save    `economymnc'

*****Checking how many distinct MNCs we have contacted
use $events_MNC, clear
quietly bys MNC_ID: gen dup=cond(_N==1,0,_n)
drop if dup>1
keep MNC_ID
tempfile distinctMNCeconomywide
save    `distinctMNCeconomywide'
use $survey_proco, clear
quietly bys MNC_ID: gen dup=cond(_N==1,0,_n)
drop if dup>1
keep MNC_ID
append using `distinctMNCeconomywide'

***************** MNC REPRESENTATIVENESS
use $events_MNC, clear
quietly bys MNC_ID: gen dup=cond(_N==1,0,_n)
drop if dup>1
keep MNC_ID
gen economywide=1

tempfile distinctMNCeconomywide
save    `distinctMNCeconomywide'

use $survey_proco, clear
quietly bys MNC_ID proco_s: gen dup=cond(_N==1,0,_n)
drop if dup>1
drop dup

gen procomer_other=(proco_s==0)
ren proco_s procomer_sample

bys MNC_ID: egen mprocomer_other =max(procomer_other)
bys MNC_ID: egen mprocomer_sample=max(procomer_sample)
quietly bys MNC_ID: gen dup=cond(_N==1,0,_n)
drop if dup>1
drop dup ID
drop procomer*
ren mprocomer_other  procomer_other
ren mprocomer_sample procomer_sample

merge 1:1 MNC_ID using `distinctMNCeconomywide'
replace economywide=1 if _m==3
replace economywide=0 if _m==1
drop _m

merge 1:1 MNC_ID using `mncs_surveyed'
gen surveyed=0
replace surveyed=1 if _m!=1

keep MNC_ID procomer_other procomer_sample economywide surveyed

tempfile MNCtargetedsurveyed
save    `MNCtargetedsurveyed'

use $mnc_info

gen vaperworker=va*1000/(trabaj*500)
keep ID year vaperworker trabaj_ ZF firm_ciiu4 firm_AE sector_g sophistication ingresosir_  exports_ 

ren ID MNC_ID
 
merge m:1 MNC_ID using `MNCtargetedsurveyed'
keep if _m==3
drop _m

keep if year==2009
replace trabaj_     = trabaj      
replace ingresosir_ = ingresosir_ /500

gen econwidesurv  =surveyed*economywide
gen procothesurv  =surveyed*procomer_other
gen procsamplesurv=surveyed*procomer_sample

label variable trabaj_ "Number of Workers"
label variable ingresosir_ "Total Sales"
label variable vaperworker "Value Added Per Worker"
label variable ZF "Free Trade Zone"

eststo clear
gen notsurveyed=1-surveyed
myttests trabaj ingresos vaperworker ZF, by(notsurveyed) 
}
display "Supplementary Table F4"
esttab, nomtitle nonumbers  ///
    cells("mu_1(fmt(a3)) mu_2 d(star pvalue(d_p))" "mu_1_se(par fmt(2)) mu_2_se(par fmt(2)) d_se(par fmt(2))" ) mlabel("Surveyed" "Not surveyed" "Difference") alignment(c) label collabels(none)

*************************************************************************************************************
** Supplementary Table F5
** Question 6 in the domestic firms survey (Question 1 in the paper)
*************************************************************************************************************

quiet{

use $answers_dom , clear
keep position_empl
label var position_empl Position

replace position=ltrim(pos)
replace position=rtrim(pos)
replace position="Assistant to CEO/President/Founder" if pos=="Asistente de Gerencia"
replace position="Assistant to CEO/President/Founder" if pos=="Asistente de Gerencia General"
replace position="Assistant to CEO/President/Founder" if pos=="Assistant manager (administrative and logistics)"
replace position="CEO/President/Founder" if pos=="ADMINISTRADOR"
replace position="CEO/President/Founder" if pos=="Administraciòn"
replace position="CEO/President/Founder" if pos=="Administración"
replace position="CEO/President/Founder" if pos=="Administrador"
replace position="CEO/President/Founder" if pos=="Administrador Región Norte"
replace position="CEO/President/Founder" if pos=="Administradora"
replace position="CEO/President/Founder" if pos=="Administrativo"
replace position="CEO/President/Founder" if pos=="DIRECTOR GENERAL"
replace position="CEO/President/Founder" if pos=="Director"
replace position="CEO/President/Founder" if pos=="Director of Special Projects and Co-Founder"
replace position="CEO/President/Founder" if pos=="Directora"
replace position="CEO/President/Founder" if pos=="Dueña/Gerente General"
replace position="CEO/President/Founder" if pos=="Dueño"
replace position="CEO/President/Founder" if pos=="General Director"
replace position="CEO/President/Founder" if pos=="General Manager"
replace position="CEO/President/Founder" if pos=="General Manager"
replace position="CEO/President/Founder" if strpos(pos, "General Manager")>0
replace position="CEO/President/Founder" if pos=="General Manager and Founder"
replace position="CEO/President/Founder" if pos=="Gerencia"
replace position="CEO/President/Founder" if pos=="Gerente"
replace position="CEO/President/Founder" if pos=="Gerente Administrativa"
replace position="CEO/President/Founder" if pos=="Gerente Administrativo"
replace position="CEO/President/Founder" if pos=="Gerente General"
replace position="CEO/President/Founder" if pos=="Gerente general"
replace position="CEO/President/Founder" if pos=="Gestión Administrativa"
replace position="CEO/President/Founder" if pos=="Owner"
replace position="CEO/President/Founder" if pos=="Owner and General Manager"
replace position="CEO/President/Founder" if pos=="PROPIETARIA"
replace position="CEO/President/Founder" if pos=="President"
replace position="CEO/President/Founder" if pos=="Presidente"
replace position="CEO/President/Founder" if pos=="Project manager"
replace position="CEO/President/Founder" if pos=="Propietario"
replace position="CEO/President/Founder" if pos=="Propietario, Gerente General"
replace position="CEO/President/Founder" if pos=="Representante Legal"
replace position="CEO/President/Founder" if pos=="Socio Gerente"
replace position="Sales/Marketing/Client Outreach Manager" if pos=="Servicio al Cliente"
replace position="Sales/Marketing/Client Outreach Manager" if pos=="Coordinadora de Mercadeo"
replace position="Sales/Marketing/Client Outreach Manager" if pos=="Director Comercial"
replace position="Sales/Marketing/Client Outreach Manager" if pos=="Director de Desarrollo Empresarial"
replace position="Sales/Marketing/Client Outreach Manager" if pos=="Encargado de ventas"
replace position="Sales/Marketing/Client Outreach Manager" if pos=="GERENTE COMERCIAL"
replace position="Sales/Marketing/Client Outreach Manager" if pos=="Gerente Comercial"
replace position="Sales/Marketing/Client Outreach Manager" if pos=="Gerente Mercadeo y Ventas"
replace position="Sales/Marketing/Client Outreach Manager" if pos=="Sales Coordinator"
replace position="Sales/Marketing/Client Outreach Manager" if pos=="Sales Director"
replace position="Sales/Marketing/Client Outreach Manager" if pos=="Ventas Corporativas"
replace position="Other Unit Manager" if pos=="Accountant"
replace position="Other Unit Manager" if pos=="Administración y Recursos Humanos"
replace position="Other Unit Manager" if pos=="Director Proyectos"
replace position="Other Unit Manager" if pos=="Director de Preconstrucción y Contrataciones"
replace position="Other Unit Manager" if pos=="Directora Financiera"
replace position="Other Unit Manager" if pos=="Ejecutiva de Cuentas"
replace position="Other Unit Manager" if pos=="Gerente Compras"
replace position="Other Unit Manager" if pos=="Gerente de Investigación y Desarrollo"
replace position="Other Unit Manager" if pos=="Jefe Contabilidad"
replace position="Other Unit Manager" if pos=="Sistemas"
replace position="Other Unit Manager" if pos=="Supervisor de Contabilidad"
replace position="Professional/Analyst" if pos=="Analista de Negocios y Operaciones"
replace position="Professional/Analyst" if pos=="Asesor Técnico"
replace position="Professional/Analyst" if pos=="Asistente Contable"
replace position="Sales/Marketing/Client Outreach Manager" if pos=="Comercial"
replace position="Professional/Analyst" if pos=="Consultora"
replace position="Assistant to CEO/President/Founder" if pos=="Encargada administrativa"
replace position="Professional/Analyst" if pos=="Ingeniero en Diseño Industrial"
replace position="Senior Partner" if pos=="Senior Partner"
replace position="Senior Partner" if pos=="Socio"
replace position="Senior Partner" if pos=="Socio Director"
replace position="Operations/Supply Chain Manager" if pos=="Directora de Operaciones"
replace position="Operations/Supply Chain Manager" if pos=="Gerente de Operaciones"
replace position="Operations/Supply Chain Manager" if pos=="Jefe de Logística"
replace position="Operations/Supply Chain Manager" if pos=="Jefe de Operaciones"
replace position="Operations/Supply Chain Manager" if pos=="Logística"
replace position="Operations/Supply Chain Manager" if pos=="Logística y Ventas"
replace position="Operations/Supply Chain Manager" if pos=="Operations Manager"
replace position="Senior Partner" if strpos(pos, "Senior Partner")>0
}

tabsort position

*************************************************************************************************************
** Supplementary Figure F2
** Question 9 in the domestic firms survey (Question 3 in the paper)
*************************************************************************************************************

quiet{
use $answers_dom , clear
gen howmany =_N
forval i=1/9 {
gen q9_`i'_n=1 
replace q9_`i'_n=2 if q9_`i'=="Sí, esta era una pequeña diferencia esperada"
replace q9_`i'_n=3 if q9_`i'=="Sí, esta era una gran diferencia esperada"
gen  q9_`i'_1=(q9_`i'_n==1)
gen  q9_`i'_2=(q9_`i'_n==2)
gen  q9_`i'_3=(q9_`i'_n==3)
egen sq9_`i'_1= total(q9_`i'_1)
replace sq9_`i'_1=sq9_`i'_1/howmany*100
egen sq9_`i'_2= total(q9_`i'_2)
replace sq9_`i'_2=sq9_`i'_2/howmany*100
egen sq9_`i'_3= total(q9_`i'_3)
replace sq9_`i'_3=sq9_`i'_3/howmany*100
drop q9_`i'_1 q9_`i'_2 q9_`i'_3 q9_`i'_n
}

keep sq9_1_* sq9_2_* sq9_3_* sq9_4_* sq9_5_* sq9_6_* sq9_7_* sq9_8_* sq9_9_*
quietly bys sq9_1_1:  gen dup = cond(_N==1,0,_n)
drop if dup>1
drop dup

tempfile befappend
save    `befappend'
forval i=1/9 {
use `befappend', clear
keep sq9_`i'_*
ren sq9_`i'_1 ans1
ren sq9_`i'_2 ans2
ren sq9_`i'_3 ans3
gen exp=`i'
tempfile option`i'
save    `option`i''
}

use `option1', clear
append using `option2'
append using `option3'
append using `option4'
append using `option5'
append using `option6'
append using `option7'
append using `option8'
append using `option9'

gen diff=ans3+ans2
gsort - diff

gen pos=_n

gen exp_lab="More reliable payment"
replace exp_lab="Advance payment" if exp==2
replace exp_lab="Larger amount" if exp==3
replace exp_lab="Longer contract" if exp==4
replace exp_lab="Learn on management" if exp==5
replace exp_lab="Learn on technology" if exp==6
replace exp_lab="Learn on operations" if exp==7
replace exp_lab="Learn on foreign dem." if exp==8
replace exp_lab="Become official supplier" if exp==9
}

quiet labmask pos, values(exp_lab)
graph hbar ans3  ans2  ans1, over(pos, ) stack percent ytitle("Percentage", size(medsmall)) ytitle(, height(5)) graphregion(fcolor(white)) b1title("Expected Difference Between MNC and Domestic Clients", size(medsmall)) b1title(, height(5)) ylabel(  , labs(small) format(%12.0fc) gstyle(shortdash)) legend(rows(1) order(1 "Big diff" 2 "Small diff" 3 "No diff") size(small)) asyvars bar(1, fcolor(black)) bar(2, fcolor(gs11)) bar(3, fcolor(white))
graph export "${path0}/results/6-appendix_f/Supplementary_Figure_F2.eps", replace

*****************************************************************************************************************
** Supplementary Figure F3
** Question 10+11 in the domestic firms (Question 5 in the paper)
*****************************************************************************************************************

quiet{
use $answers_dom , clear
drop if q10=="No, nuestra empresa no tomó medidas especiales para comenzar a abastecer a las multinacionales"

gen howmany =_N

forval i=1/10 {
gen q11_`i'_n=1 
replace q11_`i'_n=2 if q11_`i'=="Sí, nuestra empresa hizo esto pero muy poco."
replace q11_`i'_n=3 if q11_`i'=="Sí, nuestra empresa estuvo muy involucrada en este cambio"
gen  q11_`i'_1=(q11_`i'_n==1)
gen  q11_`i'_2=(q11_`i'_n==2)
gen  q11_`i'_3=(q11_`i'_n==3)
egen sq11_`i'_1= total(q11_`i'_1)
replace sq11_`i'_1=sq11_`i'_1/howmany*100
egen sq11_`i'_2= total(q11_`i'_2)
replace sq11_`i'_2=sq11_`i'_2/howmany*100
egen sq11_`i'_3= total(q11_`i'_3)
replace sq11_`i'_3=sq11_`i'_3/howmany*100
drop q11_`i'_1 q11_`i'_2 q11_`i'_3 q11_`i'_n
}

keep sq11_1_* sq11_2_* sq11_3_* sq11_4_* sq11_5_* sq11_6_* sq11_7_* sq11_8_* sq11_9_* sq11_10_*
quietly bys sq11_1_1:  gen dup = cond(_N==1,0,_n)
drop if dup>1
drop dup

tempfile befappend
save    `befappend'
forval i=1/10 {
use `befappend', clear
keep sq11_`i'_*
ren sq11_`i'_1 ans1
ren sq11_`i'_2 ans2
ren sq11_`i'_3 ans3
gen exp=`i'
tempfile option`i'
save    `option`i''
}

use `option1', clear
append using `option2'
append using `option3'
append using `option4'
append using `option5'
append using `option6'
append using `option7'
append using `option8'
append using `option9'
append using `option10'

gen diff=ans3+ans2
gsort - diff

gen pos=_n

gen exp_lab="Studied MNC activity"
replace exp_lab="Trained workers: technology" if exp==2
replace exp_lab="Trained workers: management" if exp==3
replace exp_lab="Prepared for certificates" if exp==4
replace exp_lab="Bought relevant equipment" if exp==5
replace exp_lab="Moved closer to MNCs" if exp==6
replace exp_lab="Attended more networking ev." if exp==7
replace exp_lab="Contacted MNCs directly" if exp==8
replace exp_lab="Created website/blog" if exp==9
replace exp_lab="Contacted Procomer/CINDE" if exp==10
}

quiet labmask pos, values(exp_lab)
graph hbar ans3 ans2 ans1 , over(pos, ) stack percent ytitle("Percentage", size(medsmall)) ytitle(, height(5)) graphregion(fcolor(white)) b1title("How did the firm prepare towards supplying MNCs?", size(medsmall)) b1title(, height(5)) ylabel(  , labs(small) format(%12.0fc) gstyle(shortdash)) legend(rows(1) order(3 "No" 2 "Yes, little"  1 "Yes, a lot") size(small)) asyvars bar(1, fcolor(black)) bar(2, fcolor(gs11)) bar(3, fcolor(white))

graph export "${path0}/results/6-appendix_f/Supplementary_Figure_F3.eps", replace

*****************************************************************************************************************
** Supplementary Figure F4
** Question 16+17 in the domestic firms survey (Question 8 in the paper)
*****************************************************************************************************************

quiet{
use $answers_dom , clear
drop if q16=="NO, fue relativamente fácil comenzar a suministrar a las multinacionales"

gen howmany =_N
forval i=1/8 {
gen     q17_`i'_n=1 
replace q17_`i'_n=2 if q17_`i'=="Quizás un poco importante, no central"
replace q17_`i'_n=3 if q17_`i'=="Importante"
replace q17_`i'_n=4 if q17_`i'=="Muy importante"
gen   q17_`i'_1=(q17_`i'_n==1)
gen   q17_`i'_2=(q17_`i'_n==2)
gen   q17_`i'_3=(q17_`i'_n==3)
gen   q17_`i'_4=(q17_`i'_n==4)
egen    sq17_`i'_1= total(q17_`i'_1)
replace sq17_`i'_1=sq17_`i'_1/howmany*100
egen    sq17_`i'_2= total(q17_`i'_2)
replace sq17_`i'_2=sq17_`i'_2/howmany*100
egen    sq17_`i'_3= total(q17_`i'_3)
replace sq17_`i'_3=sq17_`i'_3/howmany*100
egen    sq17_`i'_4= total(q17_`i'_4)
replace sq17_`i'_4=sq17_`i'_4/howmany*100
drop    q17_`i'_1 q17_`i'_2 q17_`i'_3 q17_`i'_4 q17_`i'_n
}

keep sq17_1_* sq17_2_* sq17_3_* sq17_4_* sq17_5_* sq17_6_* sq17_7_* sq17_8_* 
quietly bys sq17_1_1:  gen dup = cond(_N==1,0,_n)
drop if dup>1
drop dup

tempfile befappend
save    `befappend'
forval i=1/8 {
use `befappend', clear
keep sq17_`i'_*
ren  sq17_`i'_1 ans1
ren  sq17_`i'_2 ans2
ren  sq17_`i'_3 ans3
ren  sq17_`i'_4 ans4
gen  exp=`i'
tempfile option`i'
save    `option`i''
}

use `option1', clear
append using `option2'
append using `option3'
append using `option4'
append using `option5'
append using `option6'
append using `option7'
append using `option8'

gen tot=ans2+ans3+ans4
gsort - tot
gen pos=_n

gen exp_lab="Difficult to contact"
replace exp_lab="Not interest. to buy locally" if exp==2
replace exp_lab="Didn't know / trust supplier" if exp==3
replace exp_lab="Expected specific inputs" if exp==4
replace exp_lab="Expected higher quality" if exp==5
replace exp_lab="Expected faster delivery" if exp==6
replace exp_lab="Expected lower prices" if exp==7
replace exp_lab="Required large investment" if exp==8
}

quiet labmask pos, values(exp_lab)
graph hbar ans4 ans3 ans2 ans1   , over(exp_lab, ) stack percent ytitle("Percentage", size(medsmall)) ytitle(, height(5)) graphregion(fcolor(white)) b1title("Why difficult to start supplying to MNCs? MNCs...", size(medsmall)) b1title(, height(5)) ylabel(  , labs(small) format(%12.0fc) gstyle(shortdash)) legend(rows(1) order(1 "Crucial" 2 "Important" 3 "Not central" 4 "Irrelev.") size(small)) asyvars bar(1, fcolor(black)) bar(2, fcolor(gs8)) bar(3, fcolor(gs12)) bar(4, fcolor(white)) legend(size(vsmall)) graphregion(margin(45 2 2 2))
graph export "${path0}/results/6-appendix_f/Supplementary_Figure_F4.eps", replace

*****************************************************************************************************************
** Supplementary Figure F5
** Question 18 in the domestic firms survey (Question 9 in the paper)
*****************************************************************************************************************

quiet{
use $answers_dom , clear
keep q18 ID

gen t18_1=strpos(q18,"La multinacional requería productos o servicios específicos, por lo que ampliamos nuestra cartera de productos o servicios que ofrecíamos")
gen q18_1=(t18_1!=0)
drop t18_1

gen t18_2=strpos(q18,"Reemplazamos completamente los productos o servicios que ofrecíamos anteriormente, con los que demandan las multinacionales")
gen q18_2=(t18_2!=0)
drop t18_2

gen t18_3=strpos(q18,"Continuamos ofreciendo solo los mismos productos o servicios, pero la calidad y / o el precio cambiaron")
gen q18_3=(t18_3!=0)
drop t18_3

gen t18_4=strpos(q18,"Decidimos expandir nuestra capacidad productiva para poder atender las órdenes más grandes de las multinacionales")
gen q18_4=(t18_4!=0)
drop t18_4

gen t18_5=strpos(q18,"Contratamos a más trabajadores altamente calificados para ayudarnos a servir mejor a los clientes multinacionales")
gen q18_5=(t18_5!=0)
drop t18_5

gen t18_6=strpos(q18,"Nuestros trabajadores tuvieron que trabajar más duro y más horas, porque las expectativas de la multinacional eran más altas de lo que estaban acostumbrados")
gen q18_6=(t18_6!=0)
drop t18_6

gen t18_7=strpos(q18,"Cambiamos nuestra estrategia de abastecimiento (por ejemplo, se suministró de manera diferente a nivel local, se importó más)")
gen q18_7=(t18_7!=0)
drop t18_7

gen t18_8=strpos(q18,"Aprendimos de la multinacional sobre prácticas de gestión o organización")
gen q18_8=(t18_8!=0)
drop t18_8

gen t18_9=strpos(q18,"Aprendimos de la multinacional sobre tecnología relevante para nuestros productos o servicios")
gen q18_9=(t18_9!=0)
drop t18_9

gen q18_10=q18
replace q18_10=subinstr(q18_10,"La multinacional requería productos o servicios específicos, por lo que ampliamos nuestra cartera de productos o servicios que ofrecíamos", "",.)
replace q18_10=subinstr(q18_10,"Reemplazamos completamente los productos o servicios que ofrecíamos anteriormente, con los que demandan las multinacionales", "",.)
replace q18_10=subinstr(q18_10,"Continuamos ofreciendo solo los mismos productos o servicios, pero la calidad y / o el precio cambiaron", "",.)
replace q18_10=subinstr(q18_10,"Decidimos expandir nuestra capacidad productiva para poder atender las órdenes más grandes de las multinacionales", "",.)
replace q18_10=subinstr(q18_10,"Contratamos a más trabajadores altamente calificados para ayudarnos a servir mejor a los clientes multinacionales", "",.)
replace q18_10=subinstr(q18_10,"Nuestros trabajadores tuvieron que trabajar más duro y más horas, porque las expectativas de la multinacional eran más altas de lo que estaban acostumbrados", "",.)
replace q18_10=subinstr(q18_10,"Cambiamos nuestra estrategia de abastecimiento (por ejemplo, se suministró de manera diferente a nivel local, se importó más)", "",.)
replace q18_10=subinstr(q18_10,"Aprendimos de la multinacional sobre prácticas de gestión o organización", "",.)
replace q18_10=subinstr(q18_10,"Aprendimos de la multinacional sobre tecnología relevante para nuestros productos o servicios", "",.)
replace q18_10=subinstr(q18_10,", , , , , , , ", "",.)
replace q18_10=subinstr(q18_10,", , , , , ,  ", "",.)
replace q18_10=subinstr(q18_10,", , , , ,  ", "",.)
replace q18_10=subinstr(q18_10,", , , ,  ", "",.)
replace q18_10=subinstr(q18_10,", , ,  ", "",.)
replace q18_10=subinstr(q18_10,", ,", "",.)
replace q18_10=subinstr(q18_10,", ", "",.)
gen q18_11=q18_10
replace q18_11=subinstr(q18_11," ", "",.)
replace q18_10=q18_11 if q18_11==""
drop q18_11

gen q18_comm=""
replace q18_5=1   if strpos(q18_10,"Either trained more existing workers or hired new workers who were more reliable")!=0
replace q18_comm="The firm either trained more existing workers or hired new workers who were more reliable." if strpos(q18_10,"Either trained more existing workers or hired new workers who were more reliable")!=0
replace q18_10="" if strpos(q18_10,"Either trained more existing workers or hired new workers who were more reliable")!=0
replace q18_1=1   if strpos(q18_10,"El servicio se adapta de acuerdo a la necesidad del cliente")!=0
replace q18_10="" if strpos(q18_10,"El servicio se adapta de acuerdo a la necesidad del cliente")!=0
replace q18_8=1   if strpos(q18_10,"Se implementaron mejoras en salud ocupacional por las exigencias de las empresas")!=0
replace q18_comm="At the request of MNCs, the supplier has implemented changes in occupational health." if strpos(q18_10,"Se implementaron mejoras en salud ocupacional por las exigencias de las empresas")!=0
replace q18_10="" if strpos(q18_10,"Se implementaron mejoras en salud ocupacional por las exigencias de las empresas")!=0
replace q18_comm="Largest change after starting to supply to MNCs was in the mindset of MNCs, that they could finally trust the services of the supplier." if strpos(q18_10,"Realmente no se experimentaron cambioslo que cambió fue el pensar de las transnacionales que finalmente confiaron en que podíamos ofrecer lo mismo que el fabricantepero localmente.")!=0
replace q18_10="No change" if strpos(q18_10,"Realmente no se experimentaron cambioslo que cambió fue el pensar de las transnacionales que finalmente confiaron en que podíamos ofrecer lo mismo que el fabricantepero localmente.")!=0
replace q18_comm="No change" if strpos(q18_10,"ninguna")!=0
replace q18_10="No change" if strpos(q18_10,"ninguna")!=0
replace q18_comm="Firm had to increase the number of credit days." if strpos(q18_10,"AMPLIAR TIEMPOS DE CRÉDITO")!=0
replace q18_10="Firm had to increase the number of credit days." if strpos(q18_10,"AMPLIAR TIEMPOS DE CRÉDITO")!=0
replace q18_10="No change" if strpos(q18_10,"No se experimentó cambios en nuestra oferta de productos y servicios")!=0
replace q18_comm="There was no change in our offer of products and services." if strpos(q18_10,"No se experimentó cambios en nuestra oferta de productos y servicios")!=0

ren q18_10 tq18_10
gen q18_10=(tq18_10!="")
drop tq18_10

forval i=1/10 {
egen sh18_`i'= mean(q18_`i')
replace sh18_`i'= sh18_`i'*100
}

quietly bys sh18_1:  gen dup = cond(_N==1,0,_n)
drop if dup>1

keep sh18* ID
reshape long sh18_, i(ID) j(exp)

drop ID
ren sh18_ Percentage
replace Percentage=round(Percentage, 0.1)

gen     exp_lab="No change or other"
replace exp_lab="Expansion of product scope" if exp==1
replace exp_lab="Full replacement of product offer" if exp==2
replace exp_lab="Same products, but quality/price changed" if exp==3
replace exp_lab="Expansion of productive capacity" if exp==4
replace exp_lab="Hiring of more high-skilled workers" if exp==5
replace exp_lab="Employees had to work harder" if exp==6
replace exp_lab="Change in sourcing strategy" if exp==7
replace exp_lab="Learning from MNCs on management" if exp==8
replace exp_lab="Learning from MNCs on technology" if exp==9
}

quiet labmask exp, values(exp_lab)
graph hbar Percentage, over(exp, sort(1) descending lab(labsize(small)) relabel(2 `""Full replacement of" "product offer""' 3 `""Same products, but quality/price" "changed""' 5 `""Hiring of more high-skilled" "workers""')) ytitle("Percentage", size(medsmall)) ytitle(, height(5)) graphregion(fcolor(white)) b1title("Changes for firm upon becoming supplier to first MNC", size(medsmall)) b1title(, height(5)) ylabel(  , labs(medsmall) format(%12.0fc) gstyle(shortdash)) 

graph export "${path0}/results/6-appendix_f/Supplementary_Figure_F5.eps", replace

*****************************************************************************************************************
** Supplementary Table F6
** Question 19 in the domestic firms survey (Question 10) in the paper
*****************************************************************************************************************

quiet{
use $answers_dom , clear
label var q19 "Most Important Change"
}

tabsort q19

*****************************************************************************************************************
** Supplementary Figure F6
** Question 20 in the domestic firms survey (Question 11) in the paper
*****************************************************************************************************************

quiet{
use $answers_dom , clear
keep q20 ID 

gen t20_1=strpos(q20,"La multinacional no participó directamente, no brindó ninguna ayuda explícita, lidiamos con los cambios por nuestra propia cuenta")
gen q20_1=(t20_1!=0)
drop t20_1
gen t20_2=strpos(q20,"La multinacional proporcionó un modelo (")
gen q20_2=(t20_2!=0)
drop t20_2
gen t20_3=strpos(q20,"Empleados de la multinacional visitaron nuestra empresa y nos ayudaron con consejos en el proceso de ajuste (por ejemplo, la multinacional realizó auditorías a su empresa y lo guió en formas de mejorar)")
gen q20_3=(t20_3!=0)
drop t20_3
gen t20_4=strpos(q20,"Nuestros empleados realizaron visitas a la multinacional para observar partes de su producción que eran relevantes para el insumo que estábamos suministrando a la multinacional")
gen q20_4=(t20_4!=0)
drop t20_4
gen t20_5=strpos(q20,"La multinacional tenía programas de capacitación estandarizados que ofrecieron a nuestros empleados")
gen q20_5=(t20_5!=0)
drop t20_5
gen t20_6=strpos(q20,"La multinacional nos puso en contacto con otra empresa que suministra productos o servicios similares a la multinacional en otros lugares, para que nos asesore sobre las mejores prácticas")
gen q20_6=(t20_6!=0)
drop t20_6
gen t20_7=strpos(q20,"La multinacional nos ha prestado dinero o nos ha pagado por adelantado para que podamos hacer las inversiones necesarias")
gen q20_7=(t20_7!=0)
drop t20_7
gen t20_8=strpos(q20,"La multinacional es la que compro la maquinaria específica necesaria para proveer el bien/servicio  y nos lo han prestado/alquilado")
gen q20_8=(t20_8!=0)
drop t20_8
gen t20_8=strpos(q20,"La multinacional es la que compro la maquinaria específica necesaria para proveer el bien/servicio y nos lo han prestado/alquilado")
replace q20_8=1 if t20_8!=0
drop t20_8

gen q20_9=q20
replace q20_9=subinstr(q20_9,"La multinacional no participó directamente, no brindó ninguna ayuda explícita, lidiamos con los cambios por nuestra propia cuenta", "",.)
replace q20_9=subinstr(q20_9,"La multinacional proporcionó un modelo (", "",.)
replace q20_9=subinstr(q20_9,"blue print", "",.)
replace q20_9=subinstr(q20_9,") del producto o servicio deseado o alguna otra documentación relevante", "",.)
replace q20_9=subinstr(q20_9,"Empleados de la multinacional visitaron nuestra empresa y nos ayudaron con consejos en el proceso de ajuste (por ejemplo, la multinacional realizó auditorías a su empresa y lo guió en formas de mejorar)", "",.)
replace q20_9=subinstr(q20_9,"Nuestros empleados realizaron visitas a la multinacional para observar partes de su producción que eran relevantes para el insumo que estábamos suministrando a la multinacional", "",.)
replace q20_9=subinstr(q20_9,"La multinacional tenía programas de capacitación estandarizados que ofrecieron a nuestros empleados", "",.)
replace q20_9=subinstr(q20_9,"La multinacional nos puso en contacto con otra empresa que suministra productos o servicios similares a la multinacional en otros lugares, para que nos asesore sobre las mejores prácticas", "",.)
replace q20_9=subinstr(q20_9,"La multinacional nos ha prestado dinero o nos ha pagado por adelantado para que podamos hacer las inversiones necesarias", "",.)
replace q20_9=subinstr(q20_9,"La multinacional es la que compro la maquinaria específica necesaria para proveer el bien/servicio  y nos lo han prestado/alquilado", "",.)
replace q20_9=subinstr(q20_9,"La multinacional es la que compro la maquinaria específica necesaria para proveer el bien/servicio y nos lo han prestado/alquilado", "",.)
replace q20_9=subinstr(q20_9,",", "",.)
replace q20_9=subinstr(q20_9,"`""'", "",.)

gen q20_comm=""
replace q20_comm="Some MNCs pay quickly, which improves cashflow and the recovery time for investments. Does not happen with all MNCs." if strpos(q20,"Ofrecen rapidez en los pagos de los servicios lo cual le da a la empresa mayor flujo de efectivo y recuperación de la inversión.")>0
replace q20_comm="The joint development of projects has boosted the technical capacity of the supplier." if strpos(q20,"El desarrollo de proyectos en conjunto")>0
replace q20_comm="Other." if strpos(q20,"ninguna de las anteriores")>0
replace q20_2=1 if strpos(q20,"Políticas que debíamos cumplir")>0
replace q20_4=1 if strpos(q20,"nuestros vendedores visitan las empresas y solicitan la información necesaria y las  especificaciones")>0
replace q20_8=1 if strpos(q20,"En una de las tareas a realizar para completar")>0
replace q20_3=1 if strpos(q20,"Las multinacionales visitaron nuestras instalaciones para conocer nuestros procesos")>0
replace q20_comm="Employees of the MNC visit the supplier to audit its productive processes and quality management. During these audits, MNCs also learn from the practices of the supplier." if strpos(q20,"Las multinacionales visitaron nuestras instalaciones para conocer nuestros procesos")>0
replace q20_5=1 if strpos(q20, "El intercambio se ha dado principalmente mediante cursos de inducción")>0
replace q20_2=1 if strpos(q20, "El intercambio se ha dado principalmente mediante cursos de inducción")>0
replace q20_3=1 if strpos(q20, "El intercambio se ha dado principalmente mediante cursos de inducción")>0
replace q20_comm="The exchange with MNC has occurred through trainings of occupational safety, very specific and well-detailed requests of services, and meetings discussing lessons learnt." if strpos(q20, "El intercambio se ha dado principalmente mediante cursos de inducción")>0
drop q20_9
gen q20_9=(q20_comm!="")

forval i=1/9 {
egen sh20_`i'= mean(q20_`i')
replace sh20_`i'= sh20_`i'*100
}

quietly bys sh20_1:  gen dup = cond(_N==1,0,_n)
drop if dup>1

keep sh20* ID
reshape long sh20_, i(ID) j(exp)

drop ID
ren sh20_ Percentage
replace Percentage=round(Percentage, 0.1)
ren Per Percentage_sup

gen     exp_lab="Other"
replace exp_lab="No direct/perceived help" if exp==1
replace exp_lab="Shared blue print/details of expected product/service" if exp==2
replace exp_lab="Visits of MNC to supplier, audits and guidance on improvements" if exp==3
replace exp_lab="Visits of supplier to MNC, learn about relevant production process" if exp==4
replace exp_lab="Training programs for suppliers' workers" if exp==5
replace exp_lab="Connect w/ supplier elsewhere, who shares best practices" if exp==6
replace exp_lab="MNC paid in advance, helping supplier make investments" if exp==7
replace exp_lab="MNC lent necessary equipment to supplier" if exp==8
}

quiet labmask exp, values(exp_lab)
graph hbar Percentage, over(exp, sort(1) descending lab(labsize(small)) relabel(2 `""Shared blue print/details of " "expected product/service""' 3 `""Visits of MNC to supplier: audits" "and guidance on improvements""' 4`""Visits of supplier to MNC to learn" "about relevant production processes""' 5 `""Training programs for" "employees of suppliers""' 6 `""Connected w/ supplier elsewhere," "who shared best practices""' 7 `""MNC paid in advance, helping" "supplier make investments""' 8 `""MNC lent necessary equipment" "to supplier""'     )) ///
ytitle("Percentage", size(medsmall)) ytitle(, height(5)) graphregion(fcolor(white)) b1title("What help did first MNC clients provide during adjustment?", size(medsmall)) b1title(, height(5)) ylabel(  , labs(medsmall) format(%12.0fc) gstyle(shortdash))

graph export "${path0}/results/6-appendix_f/Supplementary_Figure_F6.eps", replace

*****************************************************************************************************************
** Supplementary Table F7
** Question 22 in the domestic firms survey (Question 13) in the paper
*****************************************************************************************************************

quiet{
use $answers_dom , clear
keep ID q22

gen exp=7
replace exp=1 if q22=="La multinacional no ofreció ninguna ayuda en nuestro ajuste para suministrarle, por lo que esta pregunta no se aplica"
replace exp=2 if q22=="La ayuda ofrecida NO debía ser recompensada, esto era parte de la estrategia de Responsabilidad Social Corporativa de la multinacional, no había expectativas específicas de la multinacional como consecuencia de esa ayuda"
replace exp=3 if q22=="La ayuda provista debía ser recompensada a través de precios más bajos de que los que podríamos ofrecer antes de la colaboración con la multinacional, pero para el mismo producto o servicio (misma calidad)"
replace exp=4 if q22=="La ayuda brindada tenía como objetivo recompensar al garantizar una mayor calidad del producto / servicio, con precios que no cambiaban mucho"
replace exp=5 if q22=="La ayuda brindada tenía como objetivo recompensar al garantizar una mayor calidad del producto / servicio Y TAMBIEN ofrecer precios mas bajos para esa mayor calidad"
replace exp=6 if q22=="La ayuda brindada debía ser recompensada mediante un contrato de exclusividad entre nuestra empresa y la multinacional, teníamos que convertirnos en sus proveedores exclusivos"
replace exp=1 if strpos(q22,"No ofrecieron ayuda")>0
replace exp=1 if strpos(q22,"No nos han brindado ayuda")>0
replace exp=4 if strpos(q22,"La ayuda era un insumo para ofrecer el servicio")>0
replace exp=4 if strpos(q22,"El trabajo se realiza de acuerdo a los requerimientos de la empresa unicamente")>0
replace exp=2 if strpos(q22,"La ayuda recibida no debía ser recompensada, se buscaba desarrollanos como proveedores")>0

gen     exp_lab="Other"
replace exp_lab="No direct/explicit help" if exp==1
replace exp_lab="No need for compensation, part of MNC CSR " if exp==2
replace exp_lab="Lower prices for same product/service quality" if exp==3
replace exp_lab="Better quality of product/service, same prices " if exp==4
replace exp_lab="Better quality of product/service, falling prices" if exp==5

label var exp_lab "Most Important Change"
}

tabsort exp_lab

*****************************************************************************************************************
** Supplementary Table F8
** Question 26 in the domestic firms survey (Question 15) in the paper
*****************************************************************************************************************

quiet{
use $answers_dom , clear

drop if q25=="Los clientes multinacionales y nacionales casi siempre compran diferentes productos o servicios, o diferentes calidades del mismo producto y servicio, por lo que es difícil comparar directamente los precios cobrados"
drop if q25!=""

gen exp=1
replace exp=2 if q26=="Más frecuentemente un precio más alto para el cliente multinacional"
replace exp=3 if q26=="La mayoría de los casos, el mismo precio para los dos tipos de clientes"
replace exp=4 if q26=="Más frecuentemente, un precio más bajo para el cliente multinacional"
replace exp=5 if q26=="Casi siempre un precio más bajo para el cliente multinacional"

gen     exp_lab="Almost always higher price"
label var exp_lab Answer
replace exp_lab="More frequently higher price" if exp==2
replace exp_lab="Usually same price" if exp==3
replace exp_lab="More frequently lower price" if exp==4
replace exp_lab="Almost always lower price" if exp==5
}

tabsort exp_lab

*****************************************************************************************************************
** Supplementary Table F9
** Question 27 in the domestic firms survey (Question 16) in the paper
*****************************************************************************************************************

quiet{
use $answers_dom , clear
keep q27 ID

gen exp=10
replace exp=1 if strpos(q27,"No. No hubo ningun impacto en nuestro negocio nacional")>0
replace exp=2 if strpos(q27,"Si, en general, DECIDIMOS vender MENOS a clientes nacionales")>0
replace exp=3 if strpos(q27,"Si, en general, comenzamos a vender MENOS a los clientes nacionales, porque comenzamos a producir bienes o servicios que no eran atractivos para los clientes nacionales")>0
replace exp=4 if strpos(q27,"Si, en general, comenzamos a vender MENOS a las empresas nacionales porque, a pesar de producir bienes o servicios atractivos")>0
replace exp=5 if strpos(q27,"Si, en general, comenzamos a vender MÁS a clientes nacionales, porque estábamos vendiendo productos / servicios de mejor calidad, al mismo precio que antes")>0
replace exp=6 if strpos(q27,"Si, en general,, comenzamos a vender MÁS a los clientes nacionales, porque estábamos vendiendo productos / servicios de la misma calidad, pero a precios más bajos que antes")>0
replace exp=7 if strpos(q27,"Sí, en general, comenzamos a vender MÁS a clientes nacionales, porque estábamos vendiendo productos / servicios de mejor calidad AUN a precios más altos que antes")>0
replace exp=8 if strpos(q27,"Sí, en general, comenzamos a vender MÁS a clientes nacionales, porque estábamos vendiendo nuevos productos o servicios de los que ofrecíamos antes")>0
replace exp=9 if strpos(q27,"Sí, en general, comenzamos a vender MÁS a clientes nacionales, porque vender a multinacionales nos hizo más visibles en el mercado")>0
gen q27_comm=""
replace q27_comm=q27 if exp==10
replace q27_comm="We can buy higher quantities of our own inputs and that made us more competitive in the domestic market because we got quantity discounts." if strpos(q27,"Podemos comprar más volumen de suminstros y eso nos hace más competitivos en el mercado nacional porque obtenemos mejores precios por volumen")>0
replace exp=6     if strpos(q27,"Podemos comprar más volumen de suminstros y eso nos hace más competitivos en el mercado nacional porque obtenemos mejores precios por volumen")>0
replace q27_comm="The business has been struggling overall." if strpos(q27, "en realidad ninguna de las anteriores , a estado muy dificil las ventas")>0
replace exp=6       if strpos(q27, "Los negocios con clientes nacionales se dieron después de los internacionales como una necesidad de diversificación")>0
replace q27_comm="The business with national clients came after the international ones as a need for diversification when the international business was insufficient. We currently depend on both markets. National firms represent 30% of the turnover" if strpos(q27, "Los negocios con clientes nacionales se dieron después de los internacionales como una necesidad de diversificación")>0
replace exp=2       if strpos(q27,"La empresa brinda servicios a un 95% a empresas multinacionales debido al giro del negocio.")>0
replace q27_comm="The firm is mostly focused on supplying to MNCs." if strpos(q27,"La empresa brinda servicios a un 95% a empresas multinacionales debido al giro del negocio.")>0
replace exp=5       if strpos(q27, "Se usó la referencia de multinacional para afianzar la posición de calidad y capacidad de hacer cosas")>0
replace q27_comm="The firm used the experience of selling to MNCs to improve its quality and ability to manage its business." if strpos(q27, "Se usó la referencia de multinacional para afianzar la posición de calidad y capacidad de hacer cosas")>0
replace exp=1        if strpos(q27, "en realidad ninguna de las anteriores , a estado muy dificil las ventas")>0
replace q27_comm="" if strpos(q27, "en realidad ninguna de las anteriores , a estado muy dificil las ventas")>0

gen     exp_lab="Other"
replace exp_lab="SAME" if exp==1
replace exp_lab="LESS: own decision" if exp==2
replace exp_lab="LESS: new offer not attractive, similar prices" if exp==3
replace exp_lab="LESS: attractive new offer, higher prices" if exp==4
replace exp_lab="MORE: better quality, same prices" if exp==5
replace exp_lab="MORE: same quality, lower prices" if exp==6
replace exp_lab="MORE: better quality, lower prices" if exp==7
replace exp_lab="MORE: attractive new offer" if exp==8
replace exp_lab="MORE: higher visibility" if exp==9

gen exp_lab_sum="NO IMPACT"
replace exp_lab_sum="SOLD LESS" if strpos(exp_lab,"LESS")>0
replace exp_lab_sum="SOLD MORE" if strpos(exp_lab,"MORE")>0
}

tabsort exp_lab_sum
tabsort exp_lab

******************************************************************************************************************************
** Supplementary Table F10
** Questions 28 and 29 in the domestic firms survey (Questions 17 and 18) in the paper
******************************************************************************************************************************

quiet{
use $answers_dom , clear
keep q28 q29 ID

replace q28="YES. Becoming a supplier of a first multinational improved the capacity of our company to obtain more multinational clients" if q28=="SI. Convertirse en proveedor de una primera multinacional mejoró la capacidad de la empresa para obtener más clientes multinacionales"
replace q28="NO. Finding each new multinational client is as difficult as finding the first multinational client" if q28=="NO. Encontrar a cada nuevo cliente multinacional es tan difícil como encontrar el primer cliente multinacional"

tabsort q28

drop if strpos(q28, "NO. Finding")>0
gen t29_1=strpos(q29,"Se ha hecho más fácil ganarse la confianza de más multinacionales, haciéndoles saber que en el pasado ya habíamos contado con la confianza de otros clientes multinacionales")
gen q29_1=(t29_1!=0)
drop t29_1
gen t29_2=strpos(q29,"Hemos mejorado nuestras prácticas gerenciales / organizacionales y esto ha hecho que nuestros productos / servicios sean más atractivos para más clientes multinacionales")
gen q29_2=(t29_2!=0)
drop t29_2
gen t29_3=strpos(q29,"Hemos aprendido sobre las necesidades de las multinacionales y les hemos ofrecido mejores ofertas, por lo que es más probable que obtengamos acuerdos con clientes multinacionales")
gen q29_3=(t29_3!=0)
drop t29_3
gen t29_4=strpos(q29,"Hemos ampliado nuestra cartera de productos o servicios y los nuevos productos o servicios nos hicieron más atractivos para más clientes multinacionales")
gen q29_4=(t29_4!=0)
drop t29_4
gen t29_5=strpos(q29,"Hemos mejorado la calidad de nuestros productos o servicios (SIN aumentar los precios) y esto nos ha hecho más atractivos para más clientes multinacionales")
gen q29_5=(t29_5!=0)
drop t29_5
gen t29_6=strpos(q29,"Hemos mejorado la calidad de nuestros productos o servicios y esto nos ha hecho más atractivos para más clientes multinacionales (A PESAR DE tener que aumentar los precios)")
gen q29_6=(t29_6!=0)
drop t29_6
gen t29_7=strpos(q29,"Hemos reducido nuestros precios para los mismos productos o servicios que ofrecimos anteriormente y esto nos ha hecho más atractivos para más clientes multinacionales.")
gen q29_7=(t29_7!=0)
drop t29_7
gen q29_8=q29
replace q29_8=subinstr(q29_8,"Se ha hecho más fácil ganarse la confianza de más multinacionales, haciéndoles saber que en el pasado ya habíamos contado con la confianza de otros clientes multinacionales", "",.)
replace q29_8=subinstr(q29_8,"Hemos mejorado nuestras prácticas gerenciales / organizacionales y esto ha hecho que nuestros productos / servicios sean más atractivos para más clientes multinacionales", "",.)
replace q29_8=subinstr(q29_8,"Hemos aprendido sobre las necesidades de las multinacionales y les hemos ofrecido mejores ofertas, por lo que es más probable que obtengamos acuerdos con clientes multinacionales", "",.)
replace q29_8=subinstr(q29_8,"Hemos ampliado nuestra cartera de productos o servicios y los nuevos productos o servicios nos hicieron más atractivos para más clientes multinacionales", "",.)
replace q29_8=subinstr(q29_8,"Hemos mejorado la calidad de nuestros productos o servicios (SIN aumentar los precios) y esto nos ha hecho más atractivos para más clientes multinacionales", "",.)
replace q29_8=subinstr(q29_8,"Hemos mejorado la calidad de nuestros productos o servicios y esto nos ha hecho más atractivos para más clientes multinacionales (A PESAR DE tener que aumentar los precios)", "",.)
replace q29_8=subinstr(q29_8,"Hemos reducido nuestros precios para los mismos productos o servicios que ofrecimos anteriormente y esto nos ha hecho más atractivos para más clientes multinacionales.", "",.)
replace q29_8=subinstr(q29_8,",", "",.)
replace q29_8=subinstr(q29_8,"`""'", "",.)
replace q29_8=subinstr(q29_8,".", "",.)
replace q29_8=subinstr(q29_8,"|", "",.)
gen q29_10=q29_8
replace q29_10=subinstr(q29_10," ", "",.)
gen q29_comm=""
replace q29_comm=q29_8 if q29_8!="" & q29_10!=""

drop q29_8 q29_10
gen q29_8=0
replace q29_8=1 if  q29_comm!=""

replace q29_2=1  if q29_comm=="Uno empieza a conocer la forma de hacer de negocios y la forma de manejarse de las mismas permitiéndole a uno saber a qué se enfrenta"
replace q29_3=1  if q29_comm=="Uno empieza a conocer la forma de hacer de negocios y la forma de manejarse de las mismas permitiéndole a uno saber a qué se enfrenta"
replace q29_8=0  if strpos(q29_comm,"Uno empieza a conocer la forma de hacer de negocios y la forma de manejarse de las mismas permitiéndole a uno saber a qué se enfrenta")>0
replace q29_comm="One begins to know the way of doing business and the way to handle them, allowing one to know what he is facing" if q29_comm=="Uno empieza a conocer la forma de hacer de negocios y la forma de manejarse de las mismas permitiéndole a uno saber a qué se enfrenta"

replace q29_1=1  if q29_comm=="It was easier to get other multinational clients because multinationals give recommendations to each other"
replace q29_8=0  if strpos(q29_comm,"It was easier to get other multinational clients because multinationals give recommendations to each other")>0
replace q29_7=1  if q29_comm=="sometimes the local firms offers attractive deals to the multinationals as discounts or royalties"
replace q29_8=0  if strpos(q29_comm,"sometimes the local firms offers attractive deals to the multinationals as discounts or royalties")>0
replace q29_comm="Sometimes the local firm offers attractive deals to multinationals as discounts or royalties" if q29_comm=="sometimes the local firms offers attractive deals to the multinationals as discounts or royalties"
replace q29_comm="The firm increased its profits as its higher need for inputs granted them quantity discounts. Plus, MNCs pay on time, this helped the health of their operation." if strpos(q29_comm,"Aumentamos nuestros margenes de ganancia porque podemos comprar suministros en volumenes más grandes")>0
replace q29_3=1 if q29_comm=="Mejores ofertas nuestra empresa lo interprete como personalizacion al cliente"
replace q29_8=0 if strpos(q29_comm,"Mejores ofertas nuestra empresa lo interprete como personalizacion al cliente")>0
replace q29_comm="The firm learned more about the needs of MNCs, this allowed them to tailor their offer." if q29_comm=="Mejores ofertas nuestra empresa lo interprete como personalizacion al cliente"
replace q29_2=1 if strpos(q29_comm, "The local firm has already standardized to international rules")>0
replace q29_8=0 if strpos(q29_comm, "The local firm has already standardized to international rules")>0
replace q29_comm="The local firm has already standardized to international rules." if strpos(q29_comm, "The local firm has already standardized to international rules")>0

forval i=1/8 {
egen sh29_`i'= mean(q29_`i')
replace sh29_`i'= sh29_`i'*100
egen n_`i'   = sum(q29_`i')
}

quietly bys sh29_1:  gen dup = cond(_N==1,0,_n)
drop if dup>1

keep sh29* n_* ID
tempfile beforemerge
save    `beforemerge'

keep sh29* ID
reshape long sh29_, i(ID) j(exp)
drop ID
tempfile merge1
save    `merge1'

use `beforemerge', clear

keep n_* ID
reshape long n_, i(ID) j(exp)
drop ID

merge 1:1 exp using  `merge1'
drop _m

ren n_    Frequency
ren sh29_ Percentage
replace Percentage=round(Percentage, 0.1)

gen     exp_lab="Other"
replace exp_lab="Easier to gain MNC trust" if exp==1
replace exp_lab="Improved managerial practices" if exp==2
replace exp_lab="Learned about MNC needs" if exp==3
replace exp_lab="Expanded product/service offer" if exp==4
replace exp_lab="Improved quality w/o price rise" if exp==5
replace exp_lab="Improved quality w/ price rise" if exp==6
replace exp_lab="Lowered prices on prior products/services" if exp==7

gsort - Frequency
}

list exp_lab Frequency Percentage

******************************************************************************************************************************
** Supplementary Table F11
** Question 35 in the domestic firms survey (Questions 19) in the paper
******************************************************************************************************************************

quiet{
use $answers_dom , clear

keep q35 ID
drop if q35==""

gen q35_eng="Very few to almost none"
replace  q35_eng="(Almost) all" if strpos(q35, "(Casi) todos los tratos están mediados a través de Procomer")>0
replace  q35_eng="Less than half, but some" if strpos(q35, "Menos de la mitad de los tratos están mediados a través de Procomer, pero aún hay muchos")>0

drop q35
ren q35_eng q35

label var q35 Answer
}

tabsort q35

******************************************************************************************************************************
** Supplementary Table F12
** Question 36 in the domestic firms survey (Questions 20) in the paper
******************************************************************************************************************************

quiet{
use $answers_dom , clear

keep q36 ID
keep if q36!=""

gen t36_1=strpos(q36,"Las ofertas de Procomer no son diferentes de las ofertas que conseguimos por nosotros mismos, pero nos permiten tener múltiples fuentes de ofertas")
gen q36_1=(t36_1!=0)
drop t36_1
replace q36=subinstr(q36,"Las ofertas de Procomer no son diferentes de las ofertas que conseguimos por nosotros mismos, pero nos permiten tener múltiples fuentes de ofertas", "",.)

gen t36_2=strpos(q36,"Procomer tiene un mejor acceso a los clientes multinacionales o al tipo específico de ofertas que nuestra empresa desea tener (por ejemplo, ofertas más grandes, contratos más largos, más clientes de alta tecnología, etc.)")
gen q36_2=(t36_2!=0)
drop t36_2
replace q36=subinstr(q36,"Procomer tiene un mejor acceso a los clientes multinacionales o al tipo específico de ofertas que nuestra empresa desea tener (por ejemplo, ofertas más grandes, contratos más largos, más clientes de alta tecnología, etc.)", "",.)

gen t36_3=strpos(q36,"Procomer nos da credibilidad frente a clientes multinacionales")
gen q36_3=(t36_3!=0)
drop t36_3
replace q36=subinstr(q36,"Procomer nos da credibilidad frente a clientes multinacionales","",.)

gen t36_4=strpos(q36,"Procomer nos prepara antes de cada trato específico con un cliente multinacional determinado, por lo que nos sentimos mejor preparados para iniciar acuerdos mediados por Procomer.")
gen q36_4=(t36_4!=0)
drop t36_4
replace q36=subinstr(q36,"Procomer nos prepara antes de cada trato específico con un cliente multinacional determinado, por lo que nos sentimos mejor preparados para iniciar acuerdos mediados por Procomer.", "",.)

gen t36_5=strpos(q36,"Procomer acompaña nuestros tratos con clientes multinacionales, nos brinda servicios incluso después de que se hizo el trato y está en curso")
gen q36_5=(t36_5!=0)
drop t36_5
replace q36=subinstr(q36,"Procomer acompaña nuestros tratos con clientes multinacionales, nos brinda servicios incluso después de que se hizo el trato y está en curso","",.)
replace q36=subinstr(q36,",","",.)
replace q36="" if strpos(q36,"The")==0


gen q36_6=0
replace q36_6=1 if strpos(q36,"The")>0

drop q36

forval i=1/6 {
egen t36_`i'= sum(q36_`i')
}

quietly bys t36_1:  gen dup = cond(_N==1,0,_n)
drop if dup>1
drop dup

keep t36* ID

reshape long t36_, i(ID) j(exp)
drop ID

gen exp_lab="Other"
replace exp_lab="Deals not different, just another source of deals" if exp==1
replace exp_lab="Procomer has better access to MNCs" if exp==2
replace exp_lab="Procomer offers credibility in front of MNCs" if exp==3
replace exp_lab="Procomer helps prepare the firm before the deals" if exp==4
replace exp_lab="Procomer accompanies the firm during the deals" if exp==5

ren t36_ Frequency
drop exp

gen Percentage=Frequency/15*100
replace Percentage=round(Percentage, 0.1)
gsort - Frequency
}

list exp Frequency Percentage

******************************************************************************************************************************
** Supplemmentary Table F13
** Question on HQ country in the multinational firms survey (Question 1 in the paper)
******************************************************************************************************************************

quiet {
use $answers_mnc , clear
keep ID namefirm hqcountry 
label var hqcountry "HQ country"
}

tabsort hqcountry

****************************************************************************************************************************************
** Supplementary Table F14
** Question on position of employee in the multinational firms survey (Question 2 in the paper)
****************************************************************************************************************************************

quiet{
	
use $answers_mnc , clear
keep ID namefirm position_empl

gen position_stand=""
label var position_stand "Position (Standardized)"

replace position_stand="General Manager CR Operation / Country Manager" if strpos(position_empl, "General Manager")>0
replace position_stand="General Manager CR Operation / Country Manager" if strpos(position_empl, "General Manager Costa Rica Operations")>0
replace position_stand="General Manager CR Operation / Country Manager" if strpos(position_empl, "Gerente")>0
replace position_stand="General Manager CR Operation / Country Manager" if strpos(position_empl, "Gerente General")>0
replace position_stand="General Manager CR Operation / Country Manager" if strpos(position_empl, "Gerente General")>0
replace position_stand="General Manager CR Operation / Country Manager" if strpos(position_empl, "Gerente General")>0
replace position_stand="General Manager CR Operation / Country Manager" if strpos(position_empl, "Gerente de Planta")>0
replace position_stand="General Manager CR Operation / Country Manager" if strpos(position_empl, "CEO")>0
replace position_stand="General Manager CR Operation / Country Manager" if strpos(position_empl, "Country Manager")>0
replace position_stand="General Manager CR Operation / Country Manager" if strpos(position_empl, "General Manager")>0
replace position_stand="General Manager CR Operation / Country Manager" if strpos(position_empl, "Administración General")>0
replace position_stand="General Manager CR Operation / Country Manager" if strpos(position_empl, "Director")>0
replace position_stand="General Manager CR Operation / Country Manager" if strpos(position_empl, "Director of Costa Rica Operations")>0
replace position_stand="General Manager CR Operation / Country Manager" if strpos(position_empl, "Gerente de Unicomer Costa Rica")>0
replace position_stand="General Manager CR Operation / Country Manager" if strpos(position_empl, "President and Director of Global Operation")>0
replace position_stand="General Manager CR Operation / Country Manager" if strpos(position_empl, "Site Admin")>0
replace position_stand="General Manager CR Operation / Country Manager" if strpos(position_empl, "Site Supervisor")>0
replace position_stand="General Manager CR Operation / Country Manager" if strpos(position_empl, "Production Manager")>0
replace position_stand="Supply Chain/Procurement Specialist" if strpos(position_empl, "Buyer and planner")>0
replace position_stand="Supply Chain/Procurement Specialist" if strpos(position_empl, "Encargado de Compras")>0
replace position_stand="Supply Chain/Procurement Specialist" if strpos(position_empl, "Encargado de Compras")>0
replace position_stand="Supply Chain/Procurement Specialist" if strpos(position_empl, "Analista Import / Export")>0
replace position_stand="Supply Chain/Procurement/Operations Manager " if strpos(position_empl, "Operations Manager")>0
replace position_stand="Supply Chain/Procurement/Operations Manager " if strpos(position_empl, "Operations and Logistics Manager")>0
replace position_stand="Supply Chain/Procurement/Operations Manager " if strpos(position_empl, "Purchasing Manager, Regional Buyer, Institutional Communications Manager")>0
replace position_stand="Supply Chain/Procurement/Operations Manager " if strpos(position_empl, "Responsable Departamento de Compras Locales")>0
replace position_stand="Supply Chain/Procurement/Operations Manager " if strpos(position_empl, "Superintendente de Compras")>0
replace position_stand="Supply Chain/Procurement/Operations Manager " if strpos(position_empl, "Supply Chain Director")>0
replace position_stand="Supply Chain/Procurement/Operations Manager " if strpos(position_empl, "Supply Chain Director")>0
replace position_stand="Supply Chain/Procurement/Operations Manager " if strpos(position_empl, "Supply Chain Manager")>0
replace position_stand="Supply Chain/Procurement/Operations Manager " if strpos(position_empl, "Traffic and logistics supervisor")>0
replace position_stand="Supply Chain/Procurement/Operations Manager " if strpos(position_empl, "Accounting, Controller, and Sr. Supply Chain Manager")>0
replace position_stand="Supply Chain/Procurement/Operations Manager " if strpos(position_empl, "Encargado de Abastecimiento")>0
replace position_stand="Supply Chain/Procurement/Operations Manager " if strpos(position_empl, "Financial Analyst and Head of Global Procurement")>0
replace position_stand="Supply Chain/Procurement/Operations Manager " if strpos(position_empl, "Gerente Global de Operaciones")>0
replace position_stand="Supply Chain/Procurement/Operations Manager " if strpos(position_empl, "Gerente Planeación Financiera, Gerente Compras")>0
replace position_stand="Supply Chain/Procurement/Operations Manager " if strpos(position_empl, "Gerente Planeación y Logística")>0
replace position_stand="Supply Chain/Procurement/Operations Manager " if strpos(position_empl, "Gerente de Compras")>0
replace position_stand="Supply Chain/Procurement/Operations Manager " if strpos(position_empl, "Gerente de Compras")>0
replace position_stand="Supply Chain/Procurement/Operations Manager " if strpos(position_empl, "Gerente de Compras y Logistica")>0
replace position_stand="Supply Chain/Procurement/Operations Manager " if strpos(position_empl, "Institutional Operations Manager")>0
replace position_stand="Supply Chain/Procurement/Operations Manager " if strpos(position_empl, "International Trade Manager")>0
replace position_stand="Supply Chain/Procurement/Operations Manager " if strpos(position_empl, "Gerente de Compras y Logística")>0
replace position_stand="Supply Chain/Procurement/Operations Manager " if strpos(position_empl, "Jefe de Mantenimiento y Compras")>0
replace position_stand="Supply Chain/Procurement/Operations Manager " if strpos(position_empl, "Supervisor de Contabilidad de Costos")>0
replace position_stand="Other Unit Manager" if strpos(position_empl, "Analista Financiero")>0
replace position_stand="Other Unit Manager" if strpos(position_empl, "Contador")>0
replace position_stand="Other Unit Manager" if strpos(position_empl, "Contralor")>0
replace position_stand="Other Unit Manager" if strpos(position_empl, "Director and Accountant")>0
replace position_stand="Other Unit Manager" if strpos(position_empl, "Gerente Administrativo")>0
replace position_stand="Other Unit Manager" if strpos(position_empl, "Gerente Asuntos Públicos")>0
replace position_stand="Other Unit Manager" if strpos(position_empl, "Gerente Contable")>0
replace position_stand="Other Unit Manager" if strpos(position_empl, "Gerente Financiero")>0
replace position_stand="Other Unit Manager" if strpos(position_empl, "Gerente Financiero")>0
replace position_stand="Other Unit Manager" if strpos(position_empl, "Gerente Financiero Administrativo")>0
replace position_stand="Other Unit Manager" if strpos(position_empl, "Gerente de Asuntos Gubernamentales y Relaciones Públicas")>0
replace position_stand="Other Unit Manager" if strpos(position_empl, "Gerente de Regulación y RRII")>0
replace position_stand="Other Unit Manager" if strpos(position_empl, "Head of Market Development")>0
replace position_stand="Other Unit Manager" if strpos(position_empl, "Sub Gerente")>0
}

tabsort position_stand

****************************************************************************************************************************************
** Supplementary Figure F7
** Question 8 in the multinational firms survey (Question 3 in the paper)
****************************************************************************************************************************************

quiet{
use $answers_mnc , clear

gen howmany =_N
forval i=1/8 {
gen q8_`i'_n=1 
replace q8_`i'_n=2 if q8_`i'=="Una ventaja, pero no tan importante"
replace q8_`i'_n=3 if q8_`i'=="Importante"
replace q8_`i'_n=4 if q8_`i'=="Muy importante"
gen  q8_`i'_1=(q8_`i'_n==1)
gen  q8_`i'_2=(q8_`i'_n==2)
gen  q8_`i'_3=(q8_`i'_n==3)
gen  q8_`i'_4=(q8_`i'_n==4)
egen sq8_`i'_1= total(q8_`i'_1)
replace sq8_`i'_1=sq8_`i'_1/howmany*100
egen sq8_`i'_2= total(q8_`i'_2)
replace sq8_`i'_2=sq8_`i'_2/howmany*100
egen sq8_`i'_3= total(q8_`i'_3)
replace sq8_`i'_3=sq8_`i'_3/howmany*100
egen sq8_`i'_4= total(q8_`i'_4)
replace sq8_`i'_4=sq8_`i'_4/howmany*100
drop q8_`i'_1 q8_`i'_2 q8_`i'_3 q8_`i'_4 q8_`i'_n
}

keep sq8_1_* sq8_2_* sq8_3_* sq8_4_* sq8_5_* sq8_6_* sq8_7_* sq8_8_*
quietly bys sq8_1_1:  gen dup = cond(_N==1,0,_n)
drop if dup>1
drop dup

tempfile befappend
save    `befappend'

forval i=1/8 {
use `befappend', clear
keep sq8_`i'_*
ren sq8_`i'_1 ans1
ren sq8_`i'_2 ans2
ren sq8_`i'_3 ans3
ren sq8_`i'_4 ans4
gen exp=`i'
tempfile option`i'
save    `option`i''
}

use `option1', clear
append using `option2'
append using `option3'
append using `option4'
append using `option5'
append using `option6'
append using `option7'
append using `option8'

gsort - ans4 ans3 ans2
gen pos=_n

gen     exp_lab="Dist. to HQ country"
replace exp_lab="Dist. to target markets" if exp==2
replace exp_lab="CR market itself" if exp==3
replace exp_lab="Education of workforce" if exp==4
replace exp_lab="Rel. competitive wages" if exp==5
replace exp_lab="Fiscal incentives" if exp==6
replace exp_lab="Potential local suppliers" if exp==7
replace exp_lab="Natural resources" if exp==8
}

quiet labmask pos, values(exp_lab)
graph hbar ans4 ans3 ans2 ans1, over(pos, ) stack percent ytitle("Percentage", size(medsmall)) ytitle(, height(5)) graphregion(fcolor(white)) b1title("Factors affecting MNC decision to come to CR", size(medsmall)) b1title(, height(5)) ylabel(  , labs(small) format(%12.0fc) gstyle(shortdash)) legend(rows(1) order(1 "Critical" 2 "Important" 3 "A plus only" 4 "Irrelev.") size(vsmall))  asyvars bar(1, fcolor(black)) bar(2, fcolor(gs5)) bar(3, fcolor(gs11)) bar(4, fcolor(gs15)) graphregion(margin(10 2 2 2))

graph export "${path0}/results/6-appendix_f/Supplementary_Figure_F7.eps", replace

****************************************************************************************************************************************
** Supplementary Figure F8
** Question 9 in the multinational firms survey (Question 4 in the paper)
****************************************************************************************************************************************

quiet{
use $answers_mnc , clear

gen howmany =_N
forval i=1/8 {
gen q9_`i'_n=1 
replace q9_`i'_n=2 if q9_`i'=="Una ventaja, pero no tan importante"
replace q9_`i'_n=3 if q9_`i'=="Importante"
replace q9_`i'_n=4 if q9_`i'=="Muy importante"
gen  q9_`i'_1=(q9_`i'_n==1)
gen  q9_`i'_2=(q9_`i'_n==2)
gen  q9_`i'_3=(q9_`i'_n==3)
gen  q9_`i'_4=(q9_`i'_n==4)
egen sq9_`i'_1= total(q9_`i'_1)
replace sq9_`i'_1=sq9_`i'_1/howmany*100
egen sq9_`i'_2= total(q9_`i'_2)
replace sq9_`i'_2=sq9_`i'_2/howmany*100
egen sq9_`i'_3= total(q9_`i'_3)
replace sq9_`i'_3=sq9_`i'_3/howmany*100
egen sq9_`i'_4= total(q9_`i'_4)
replace sq9_`i'_4=sq9_`i'_4/howmany*100
drop q9_`i'_1 q9_`i'_2 q9_`i'_3 q9_`i'_4 q9_`i'_n
}

keep sq9_1_* sq9_2_* sq9_3_* sq9_4_* sq9_5_* sq9_6_* sq9_7_* sq9_8_*
quietly bys sq9_1_1:  gen dup = cond(_N==1,0,_n)
drop if dup>1
drop dup

tempfile befappend
save    `befappend'

forval i=1/8 {
use `befappend', clear
keep sq9_`i'_*
ren sq9_`i'_1 ans1
ren sq9_`i'_2 ans2
ren sq9_`i'_3 ans3
ren sq9_`i'_4 ans4
gen exp=`i'
tempfile option`i'
save    `option`i''
}

use `option1', clear
append using `option2'
append using `option3'
append using `option4'
append using `option5'
append using `option6'
append using `option7'
append using `option8'

gsort - ans4 -ans3 - ans2
gen pos=_n

gen     exp_lab="Dist. to HQ country"
replace exp_lab="Dist. to target markets" if exp==2
replace exp_lab="CR market itself" if exp==3
replace exp_lab="Education of workforce" if exp==4
replace exp_lab="Rel. competitive wages" if exp==5
replace exp_lab="Fiscal incentives" if exp==6
replace exp_lab="Potential local suppliers" if exp==7
replace exp_lab="Natural resources" if exp==8
}

quiet labmask pos, values(exp_lab)
graph hbar ans4 ans3 ans2 ans1, over(pos, ) stack percent ytitle("Percentage", size(medsmall)) ytitle(, height(5)) graphregion(fcolor(white)) b1title("Factors affecting MNC decision to stay and invest more in CR", size(medsmall)) b1title(, height(5)) ylabel(  , labs(small) format(%12.0fc) gstyle(shortdash)) legend(rows(1) order(1 "Critical" 2 "Important" 3 "A plus only" 4 "Irrelev.") size(vsmall))   asyvars bar(1, fcolor(black)) bar(2, fcolor(gs5)) bar(3, fcolor(gs11)) bar(4, fcolor(gs15))  graphregion(margin(10 2 2 2))

graph export "${path0}/results/6-appendix_f/Supplementary_Figure_F8.eps", replace

****************************************************************************************************************************************
** Supplementary Table F15
** Question 10 in the multinational firms survey (Question 5 in the paper)
****************************************************************************************************************************************

quiet{
use $answers_mnc , clear

gen howmany =_N
forval i=1/15 {
gen q10_`i'_n=1 
replace q10_`i'_n=2 if q10_`i'=="2: Útil, pero no es un factor decisivo"
replace q10_`i'_n=3 if q10_`i'=="3: Importante"
replace q10_`i'_n=4 if q10_`i'=="4: Muy importante"
replace q10_`i'_n=5 if q10_`i'=="5: De importancia crítica"
gen  q10_`i'_1=(q10_`i'_n==1)
gen  q10_`i'_2=(q10_`i'_n==2)
gen  q10_`i'_3=(q10_`i'_n==3)
gen  q10_`i'_4=(q10_`i'_n==4)
gen  q10_`i'_5=(q10_`i'_n==5)
egen sq10_`i'_1= total(q10_`i'_1)
replace sq10_`i'_1=sq10_`i'_1/howmany*100
egen sq10_`i'_2= total(q10_`i'_2)
replace sq10_`i'_2=sq10_`i'_2/howmany*100
egen sq10_`i'_3= total(q10_`i'_3)
replace sq10_`i'_3=sq10_`i'_3/howmany*100
egen sq10_`i'_4= total(q10_`i'_4)
replace sq10_`i'_4=sq10_`i'_4/howmany*100
egen sq10_`i'_5= total(q10_`i'_5)
replace sq10_`i'_5=sq10_`i'_5/howmany*100
drop q10_`i'_1 q10_`i'_2 q10_`i'_3 q10_`i'_4 q10_`i'_5 q10_`i'_n
}

keep sq10_*
quietly bys sq10_1_1:  gen dup = cond(_N==1,0,_n)
drop if dup>1
drop dup

tempfile befappend
save    `befappend'

forval i=1/15 {
use `befappend', clear
keep sq10_`i'_*
ren sq10_`i'_1 ans1
ren sq10_`i'_2 ans2
ren sq10_`i'_3 ans3
ren sq10_`i'_4 ans4
ren sq10_`i'_5 ans5
gen exp=`i'
tempfile option`i'
save    `option`i''
}

use `option1', clear
append using `option2'
append using `option3'
append using `option4'
append using `option5'
append using `option6'
append using `option7'
append using `option8'
append using `option9'
append using `option10'
append using `option11'
append using `option12'
append using `option13'
append using `option14'
append using `option15'

gen rank= ans5
gsort - rank
gen pos=_n

gen     exp_lab="Distance supplier-MNC"
replace exp_lab="Will to move closer" if exp==2
replace exp_lab="Prior experience w/ MNCs" if exp==3
replace exp_lab="Prior experience exporting" if exp==4
replace exp_lab="Same HQ country" if exp==5
replace exp_lab="Being foreign-owned" if exp==6
replace exp_lab="Be part of a FTZ" if exp==7
replace exp_lab="Price of inputs" if exp==8
replace exp_lab="Quality of inputs" if exp==9
replace exp_lab="Will or ability to adapt" if exp==10
replace exp_lab="Foreign language" if exp==11
replace exp_lab="Reliability, traceability etc." if exp==12
replace exp_lab="ISO certificates" if exp==13
replace exp_lab="Productive capacity" if exp==14
replace exp_lab="Will or ability to invest" if exp==15

replace ans1=round(ans1, 0.1)
replace ans2=round(ans2, 0.1)
replace ans3=round(ans3, 0.1)
replace ans4=round(ans4, 0.1)
replace ans5=round(ans5, 0.1)

order exp_lab ans5 ans4 ans3 ans2 ans1
}

list exp_lab ans5 ans4 ans3 ans2 ans1 

****************************************************************************************************************************************
** Supplementary Table F16
** Questions 11 and 12 in the multinational firms survey (Question 6 in the paper)
****************************************************************************************************************************************

quiet{
use $answers_mnc , clear

drop if strpos(q11,"NO")>0

gen t12_1=strpos(q12,"La multinacional proporciona un manual de instrucciones (")
gen q12_1=(t12_1!=0)
drop t12_1

gen t12_2=strpos(q12,"Empleados de la multinacional visitan el proveedor y lo ayudan con consejos en el proceso de ajuste (por ejemplo, la multinacional realiza auditorías al proveedor y lo guia en formas de mejorar)")
gen q12_2=(t12_2!=0)
drop t12_2

gen t12_3=strpos(q12,"Empleados del proveedor están invitados a visitar la multinacional para observar partes de su producción que son relevantes para los insumos que van a suministrar a la multinacional")
gen q12_3=(t12_3!=0)
drop t12_3

gen t12_4=strpos(q12,"La multinacional tiene programas de capacitación estandarizados que la multinacional ofrece a los empleados de proveedores locales")
gen q12_4=(t12_4!=0)
drop t12_4

gen t12_5=strpos(q12,"La multinacional pone al proveedor en contacto con otra empresa que suministra productos o servicios similares a la multinacional en otros lugares, para asesorar al nuevo proveedor sobre las mejores prácticas")
gen q12_5=(t12_5!=0)
drop t12_5

gen t12_6=strpos(q12,"La multinacional presta dinero o le paga a la empresa por adelantado para que la empresa pueda realizar las inversiones necesarias")
gen q12_6=(t12_6!=0)
drop t12_6

gen t12_7=strpos(q12,"La multinacional es la que compra la maquinaria específica necesaria para proveer el bien/servicio y se la presta/alquila al proveedor local")
gen q12_7=(t12_7!=0)
drop t12_7

gen q12_8=q12
replace q12_8=subinstr(q12_8,"La multinacional proporciona un manual de instrucciones (", "",.)
replace q12_8=subinstr(q12_8,"blue print", "",.)
replace q12_8=subinstr(q12_8,") del producto o servicio deseado o alguna otra documentación relevante", "",.)
replace q12_8=subinstr(q12_8,"Empleados de la multinacional visitan el proveedor y lo ayudan con consejos en el proceso de ajuste (por ejemplo, la multinacional realiza auditorías al proveedor y lo guia en formas de mejorar)", "",.)
replace q12_8=subinstr(q12_8,"Empleados del proveedor están invitados a visitar la multinacional para observar partes de su producción que son relevantes para los insumos que van a suministrar a la multinacional", "",.)
replace q12_8=subinstr(q12_8,"La multinacional tiene programas de capacitación estandarizados que la multinacional ofrece a los empleados de proveedores locales", "",.)
replace q12_8=subinstr(q12_8,"La multinacional pone al proveedor en contacto con otra empresa que suministra productos o servicios similares a la multinacional en otros lugares, para asesorar al nuevo proveedor sobre las mejores prácticas", "",.)
replace q12_8=subinstr(q12_8,"La multinacional presta dinero o le paga a la empresa por adelantado para que la empresa pueda realizar las inversiones necesarias", "",.)
replace q12_8=subinstr(q12_8,"La multinacional es la que compra la maquinaria específica necesaria para proveer el bien/servicio y se la presta/alquila al proveedor local", "",.)
replace q12_8=subinstr(q12_8,"La multinacional es la que compra la maquinaria específica necesaria para proveer el bien/servicio  y se la presta/alquila al proveedor local", "",.)

gen q12_comm=""
replace q12_comm="The multinational helps the supplier develop quality systems." if strpos(q12,"The multinational develops the quality of the supplier’s product / service")>0
replace q12_comm="Although no specific machinery or instruments have been purchased for the supplier, the multinational has checked whether the supplier will require something extremely specific to the input requested. In this sense, the multinational has purchased molds that they lend to the supplier while the supplier produces its orders, but the supplier must have the right machinery to be able to use the mold. In any case, the mold is property of the multinational, it is lent to suppliers only to provide the service." if strpos(q12,"Although no specific machinery or instruments have been purchased for the supplier, the multinational has checked whether the supplier will require something extremely specific to the input requested. In this sense, the multinational has purchased molds that they lend to the supplier while the supplier produces its orders, but the supplier must have the right machinery to be able to use the mold. In any case, the mold is property of the multinational, it is lent to suppliers only to provide the service.")>0
replace q12_comm="MNCs assign HR resources for the development of suppliers" if strpos(q12,"Assignment of HR resources for the development of suppliers")>0
replace q12_comm="MNC shares the schedule of input needs ahead of time to ensure timely supply." if strpos(q12,"Se comparte el programa de necesidades para que puedan suplir a tiempo")>0
replace q12_comm="MNC offers advice on FTZ and other topics, with the objective that the supplier is able to provide the product or service needed." if strpos(q12,"advisory about FTZ and other topics, with the objective that the supplier is able to provide the product or service needed")>0
drop q12_8
gen q12_8=(q12_comm!="")

forval i=1/8 {
egen sh12_`i'= mean(q12_`i')
replace sh12_`i'= sh12_`i'*100
}

quietly bys sh12_1:  gen dup = cond(_N==1,0,_n)
drop if dup>1

keep sh12* ID
reshape long sh12_, i(ID) j(exp)

drop ID
ren sh12_ Percentage

gen       exp_lab="Other"
label var exp_lab "Support"

replace exp_lab="Share blue print/details of expected product/service" if exp==1
replace exp_lab="Visits of MNC to supplier, audits and guidance on improvements" if exp==2
replace exp_lab="Visits of supplier to MNC, learn about relevant production process" if exp==3
replace exp_lab="Training programs for suppliers' workers" if exp==4
replace exp_lab="Connect w/ supplier elsewhere, who shares best practices" if exp==5
replace exp_lab="MNC pays in advance, helping supplier make investments" if exp==6
replace exp_lab="MNC lends necessary equipment to supplier" if exp==7

gen Frequency=Percentage * 40 / 100
replace Percentage=round(Percentage, 0.1)
gsort - Percentage
order exp_lab Frequency Percentage
}

list exp_lab Frequency Percentage

display "Question 8 in the paper includes anecdotes recorded in q12_comm"

****************************************************************************************************************************************
** Supplementary Table F17
** Questions 14 and 15 in the multinational firms survey (Question 9 in the paper)
****************************************************************************************************************************************

quiet{
use $answers_mnc , clear

drop if strpos(q11,"NO")>0
keep ID namefirm q14 q15

gen exp_lab="Other"

replace exp_lab="Not to be compensated, part of CSR" if q14=="El soporte proporcionado NO está destinado a ser correspondido. Por ejemplo, este apoyo es parte de la estrategia de Responsabilidad Social Corporativa de la multinacional"
replace exp_lab="Quickly falling prices, same product/service" if q14=="El soporte debe ser correspondido a través de precios más bajos a CORTO PLAZO que los precios que la empresa podría ofrecer antes de la colaboración con la multinacional, para el mismo producto o servicio"
replace exp_lab="Gradually falling prices, same product/service" if q14=="El soporte debe ser correspondido a través de una tendencia de precios GRADUALMENTE más bajos que los precios que la empresa podría ofrecer antes de la colaboración con la multinacional, pero para el mismo producto o servicio"
replace exp_lab="Increasing quality, prices not changing much" if q14=="El soporte debe ser correspondido asegurando una mayor calidad del producto / servicio, PERO con precios que no cambian mucho"
replace exp_lab="Increasing quality, falling prices" if q14=="El soporte debe ser correspondido asegurando una mayor calidad del producto / servicio Y con los precios ofrecidos cayendo también"
replace exp_lab="Exclusivity contract b/n MNC and supplier" if q14=="El soporte debe ser correspondido por una exclusividad entre la empresa y la multinacional, la empresa debe convertirse en un proveedor exclusivo"
}

tabsort exp_lab 

display "Question 10 in the paper gives anecdotes included in q15 in the multinationals' survey"

******************************************************************************************************************************************
** Supplementary Table F18
** Questions 16, 17 and 18 in the multinational firms survey (Question 11, 12 and 13 in the paper)
******************************************************************************************************************************************
quiet{
use $answers_mnc , clear

keep ID namefirm q16 q17 q18
gen keep_yes=(q16!="" | q17!="" | q18!="")
keep if keep_yes==1

gen q16_stand=""
replace q16_stand="Stability and predictability" if strpos(q16, "The first most important gain/benefit/advantage for Costa Rican firms is stability.")>0
replace q16_stand="Stability and predictability" if strpos(q16, "The first most important benefit of supplying to multinationals has to do with the fact that suppliers enter a stable business relationship.")>0
replace q16_stand="Stability and predictability" if strpos(q16, "Multinationals are very robust financially. Even if they require 30/60/90 days of credit, the multinational will indisputably pay its suppliers.")>0
replace q16_stand="Stability and predictability" if strpos(q16, "The most important benefit to the domestic suppliers is the stability that they can achieve in their business. Supplying to multinationals brings predictability for these firms, allowing them to grow.")>0
replace q16_stand="Stability and predictability" if strpos(q16, "When working with the multinational, the supplier gets a client that doesn’t fall behind with payments.")>0
replace q16_stand="Stability and predictability" if strpos(q16, "When working with the multinational, the supplier gets a client who is punctual in its payment deadlines.")>0
replace q16_stand="Stability and predictability" if strpos(q16, "The first most important gain / benefit / advantage for Costa Rican firms is stability and growth. Particularly, the medical cluster records an 8% annual growth. Therefore, starting to a multinational in this sector will lead to a very stable business, they would never have to doubt whether they will receive their respective payments.")>0
replace q16_stand="Stability and predictability" if strpos(q16, "The first most important gain / benefit / advantage for Costa Rican firms is the contract length.")>0
replace q16_stand="Stability and predictability" if strpos(q16, "Suppliers acquire a long lasting business relationship working with the multinational.")>0
replace q16_stand="Stability and predictability" if strpos(q16, "The supplier acquires a stable client when starting to work with a multinational, the multinational won’t make sudden changes that could affect the supplier.")>0
replace q16_stand="Learning opportunities" if strpos(q16, "The first most important gain / benefit / advantage for Costa Rican firms is the standardization of its processes.")>0
replace q16_stand="Learning opportunities" if strpos(q16, "Calidad")>0
replace q16_stand="Learning opportunities" if strpos(q16, "An advantage of working with this multinational is that the supplier can organize its operations and arrange a supply chain to improve its economic income.")>0
replace q16_stand="Learning opportunities" if strpos(q16, "Our multinational offers explicit help to its new suppliers, helps them in the adaptation period. This information is valuable beyond their contract with us.")>0
replace q16_stand="Learning opportunities" if strpos(q16, "The most important gain to suppliers of multinationals comes in the form of supplier development trainings offered by the multinationals. The goal of these trainings is to empower the supplier to deliver at the standards expected by the multinational.")>0
replace q16_stand="Learning opportunities" if strpos(q16, "The largest gain to the supplier comes from the implementation of new services the supplier didn’t provide (or consider providing) before.")>0
replace q16_stand="Learning opportunities" if strpos(q16, "The first most important gain to Costa Rican firms comes in the form of the management systems that these firms start using while working together with a multinational.")>0
replace q16_stand="Scale and global opportunities" if strpos(q16, "The largest gain is in the ability to access markets of larger volumes, as opposed to just satisfying local and sporadic demand.")>0
replace q16_stand="Scale and global opportunities" if strpos(q16, "Once a firm joins the list of approved suppliers for a given commodity, opportunities are global for that supplier within the organization.")>0
replace q16_stand="Scale and global opportunities" if strpos(q16, "The most important benefit is the opportunity of growth for the supplier, the opening of new markets outside of Costa Rica.")>0
replace q16_stand="Scale and global opportunities" if strpos(q16, "Mayores negocios")>0
replace q16_stand="Scale and global opportunities" if strpos(q16, "A benefit of working with the multinational is that it allows the supplier to get better prices for the raw materials through bulk purchases.")>0
replace q16_stand="Scale and global opportunities" if strpos(q16, "An advantage is that, as the company is a multinational client, if the supplier does a good job, it could get other business opportunities (to work with other affiliates).")>0
replace q16_stand="Scale and global opportunities" if strpos(q16, "The first most important gain / benefit / advantage for Costa Rican firms is an opening of market opportunities. Regarding firm growth, after supplying to a multinational the doors are opened to compete for new business opportunities with any other multinational, since the standards of multinationals are very similar among themselves.")>0
replace q16_stand="Reputation" if strpos(q16, "The first most important gain / benefit / advantage for Costa Rican firms is the improvement in their reputation. Starting to supply a multinational client allows local firms to expand their portfolios not only locally but also regionally, it gives access to more business opportunities.")>0
replace q16_stand="None" if q16==""
}

display "Left panel of Table F18"
tabsort q16_stand

quiet{
gen q17_stand=""

replace q17_stand="Stability and predictability" if strpos(q17, "Reliable payment, predictability.")>0
replace q17_stand="Stability and predictability" if strpos(q17, "Our reliability of payment is also an advantage. In addition, it has happened that we have committed to purchase from a given firm for a certain period, to reassure them towards their decision to make a certain investment needed for our contract.")>0
replace q17_stand="Stability and predictability" if strpos(q17, "Entrega a tiempo")>0
replace q17_stand="Stability and predictability" if strpos(q17, "The multinational is a stable and trustworthy client in terms of payments. The multinational has more credibility because it’s located in a FTZ and under the assessment of Procomer.")>0
replace q17_stand="Stability and predictability" if strpos(q17, "The supplier is assured to be paid on the agreed dates, because the multinational has a healthy financial status.")>0
replace q17_stand="Stability and predictability" if strpos(q17, "When working with the multinational, the supplier is guaranteed to have contracts for a certain amount of time.")>0
replace q17_stand="Stability and predictability" if strpos(q17, "The second most important gain/benefit/advantage for Costa Rican firms is the possibility that the multinational becomes an investment partner. When they have a good supplier that has supplied well its services, the multinational can consider financing its operations, and that in turn will provide financial stability. In Costa Rica, it has not yet occurred, but it is a corporate practice to finance machinery that will be then amortized through the price of the inputs.")>0
replace q17_stand="Learning opportunities" if strpos(q17, "Experiencia de hacer negocios con empresas multinacionales")>0
replace q17_stand="Learning opportunities" if strpos(q17, "Another advantage is that the supplier can improve its management in general. For example, the supplier organizes its operations such that it can upgrade its facilities and maintain its equipment in good conditions, to be sure that it can produce whatever the client needs, and to shorten the deadlines of product/service delivery.")>0
replace q17_stand="Learning opportunities" if strpos(q17, "The second most important benefit comes from the know-how that firms acquire when supplying to multinationals, particularly the know-how on the needs and expectations of multinationals.")>0
replace q17_stand="Learning opportunities" if strpos(q17, "The second most important benefit of supplying to multinationals has to do with the opportunities of development that open up for these firms. Multinationals are in the ``big league.” Any firm that manages to approach multinationals can learn a lot, of course, as long as it is willing to keep up with the expectations of a firm in the ``big league.”")>0
replace q17_stand="Learning opportunities" if strpos(q17, "The second most important benefit is the opening of new doors, of new opportunities with similar clients. Each of these new clients comes with learning opportunities that can be useful in the future.")>0
replace q17_stand="Learning opportunities" if strpos(q17, "The second most important gain/benefit/advantage for Costa Rican firms is the knowledge transfer they receive from companies with greater experience and the experience they obtain from the linkage. After making the first contact with a multinational, it is more feasible to contact other multinationals because their first relationship is a good reference for future clients.")>0
replace q17_stand="Learning opportunities" if strpos(q17, "The second most important gain/benefit/advantage for Costa Rican firms is the improvement in their governance structure and quality control.")>0
replace q17_stand="Learning opportunities" if strpos(q17, "The second most important gain/benefit/advantage for Costa Rican firms is the knowledge gained, both the one provided by the multinational and the one they seek by themselves. The entire adaptation process prepares suppliers so that, from that point on, they can access more customers and more markets thanks to their better training.")>0
replace q17_stand="Learning opportunities" if strpos(q17, "The second most important gain/benefit/advantage for Costa Rican firms is the professionalization of its workforce.")>0
replace q17_stand="Learning opportunities" if strpos(q17, "The second most important advantage to suppliers of multinationals comes from the experience and the exposure. The experience after becoming suppliers to multinationals represents a process of training and growth. These suppliers to multinationals are also exposed to new markets.")>0
replace q17_stand="Learning opportunities" if strpos(q17, "The second largest gain to the supplier is the ability to innovate in the services it offers, also as a way to respond to the requests of the multinational. Hand in hand with innovation, suppliers offered improved services and adapted them to the required standards in the market.")>0
replace q17_stand="Scale and global opportunities" if strpos(q17, "The multinational makes bulk purchases which allow the supplier to find competitive prices.")>0
replace q17_stand="Scale and global opportunities" if strpos(q17, "When working with the multinational, the supplier gets a client that renovates contracts easily.")>0
replace q17_stand="Scale and global opportunities" if strpos(q17, "The second most important gain/benefit/advantage for Costa Rican firms is the possibility to expand. Businesses with multinationals usually are of higher volumes, so the profits will be greater, and this is an opportunity for suppliers to grow and expand.")>0
replace q17_stand="Scale and global opportunities" if strpos(q17, "The second most important gain comes in the form of exposure; once a supplier becomes a corporate ally, this opens up opportunities for these suppliers also in other sites of the same multinational, in other countries")>0
replace q17_stand="Reputation" if strpos(q17, "The second largest gain goes to the reputation of the supplier. Once one MNC uses a given supplier, given the high expectations of MNCs, if that initial deal goes well, the news spreads to other MNCs that have similar requirements.")>0
replace q17_stand="None" if q17==""
}

display "Middle panel of Table F18"
tabsort q17_stand

quiet{
gen q18_stand=""

replace q18_stand="Stability and predictability" if strpos(q18, "The third most important advantage to the supplier is the guarantee of predictable orders. This backs up whatever investments the supplier has made. Doing business with a multinational is significantly less risky than with domestic firms, it is less frequent that the multinational goes bankrupt in an unexpected way or changes its orders.")>0
replace q18_stand="Stability and predictability" if strpos(q18, "An advantage of working with the multinational is that, normally, business deals are long-lasting, the supplying relation is durable in time.")>0
replace q18_stand="Learning opportunities" if strpos(q18, "An advantage of working with the multinational is the feedback and knowledge that the supplier gets, from the contact and learning process between the two companies.")>0
replace q18_stand="Learning opportunities" if strpos(q18, "The third largest gain / benefit / advantage derived from becoming a supplier to multinationals are the improvements and the strengthening of the management model of the supplier, both in terms of production and service provision. The modus operandi  a supplier learns during the collaboration with multinationals is a gain in several ways. If the supplier manages to standardize processes and apply the same principles for the rest of clients, the supplier will always win because it is better prepared – this gain is particularly important for SMEs.")>0
replace q18_stand="Learning opportunities" if strpos(q18, "The third largest gain / benefit / advantage obtained from becoming suppliers to multinationals has to do with improvements in their corporate social responsibility (the CSR practices of the multinational are passed down to the supplier).")>0
replace q18_stand="Learning opportunities" if strpos(q18, "When working with the multinational, the supplier gets a client that is open to hearing and considering new ideas.")>0
replace q18_stand="Learning opportunities" if strpos(q18, "The third most important benefit is to the workers of suppliers. These workers will be exposed to new practices, new ways of working, new criteria of evaluation of their work. There are no explicit trainings for these workers, only learned by doing.")>0
replace q18_stand="Learning opportunities" if strpos(q18, "The third largest gain / benefit / advantage obtained from becoming suppliers to multinationals is the technological development")>0
replace q18_stand="Learning opportunities" if strpos(q18, "The third largest gain / benefit / advantage obtained from becoming suppliers to multinationals is the standardization of their production process. Multinationals often set a reference in the market with the standards they request. By demanding suppliers to meet those standards and guiding them along the way to achieve it, the multinational forces them to adopt those guidelines for their own operation.")>0
replace q18_stand="Learning opportunities" if strpos(q18, "The third most important benefit of supplying to multinationals has to do with the long-term business opportunity. Costa Rican business owners sometimes have a short-termist view of their business, for instance not saving and investing for the long-term. When a business opportunity with a multinational comes to them, sometimes they don’t appreciate the full long-term potential of that opportunity. This requires from local suppliers to shift to a long-term business mentality, in terms of finances, of management etc.")>0
replace q18_stand="Learning opportunities" if strpos(q18, "The third largest gain from becoming suppliers to multinationals comes from the trainings and the support that are continuously received from the multinational, from both the Costa Rican affiliate and affiliates in other countries. The multinational has a very strong relationship with the headquarters, where they count on experienced professionals who meet the suppliers every time they visit Costa Rica to train them and support their work.")>0
replace q18_stand="Learning opportunities" if strpos(q18, "The multinational tries to be really organized in its orders; it manages its stock in such a way that emergency orders are not needed, as much as possible.")>0
replace q18_stand="Learning opportunities" if strpos(q18, "Precio")>0
replace q18_stand="Learning opportunities" if strpos(q18, "When working with the multinational, the supplier providing the service gets competitive prices.")>0
replace q18_stand="Scale and global opportunities" if strpos(q18, "Se convierten en exportadores indirectos")>0
replace q18_stand="Scale and global opportunities" if strpos(q18, "The third most important benefit is the volume of the orders. Suppliers might even end up supplying to other plants of the same multinational.")>0
replace q18_stand="Scale and global opportunities" if strpos(q18, "The third largest gain / benefit / advantage obtained from becoming suppliers to multinationals is the possibility of, eventually, getting to export their product / service to other affiliates of the same multinational in other countries.")>0
replace q18_stand="Scale and global opportunities" if strpos(q18, "The third largest gain is the ripple effect to suppliers of suppliers. When the direct supplier grows, so do its suppliers. This is how Establishment Labs hopes to help the overall economy.")>0
replace q18_stand="Scale and global opportunities" if strpos(q18, "A benefit of working with the multinational is that it allows the supplier to get better prices for the raw materials through bulk purchases.")>0
replace q18_stand="Reputation" if strpos(q18, "The third largest gain to the supplier goes to its reputation. It is an advantage to put their name next to the one of the multinational, the image the supplier reflects changes when they have worked with a multinational. This also implies a great opportunity to make important strategic alliances.")>0
replace q18_stand="None" if q18==""
}

display "Right panel of Table F18"
tabsort q18_stand

******************************************************************************************************************************************
** Supplementary Table F19
** Questions 19, 20 and 21 in the multinational firms survey (Questions 14, 15 and 16 in the paper)
******************************************************************************************************************************************
quiet{
use $answers_mnc , clear

keep ID namefirm q19 q20 q21
gen keep_yes=(q19!="" | q20!="" | q21!="")
keep if keep_yes==1

gen q19_stand=""
replace q19_stand="Financial or legal risk" if strpos(q19, "A risk that the suppliers is exposed to is a lawsuit in case it doesn’t comply with its agreements or does its job incorrectly.")>0
replace q19_stand="Financial or legal risk" if strpos(q19, "A disadvantage of working with the multinational is its payment policy, specifically using credit methods and having really long payment terms (around 50 days).")>0
replace q19_stand="Financial or legal risk" if strpos(q19, "A first large risk comes from the volumes ordered by multinationals. The supplier might need to invest a lot to live up to its large orders. However, if the supplier is unable to deliver the expected level of quality and service, it might lose the contract and get in trouble because of the investment made. It is not the policy of the multinational to sign long-term contracts with a supplier because they cannot commit to continue a contract with a supplier that does not deliver what it is supposed to deliver time after time.")>0
replace q19_stand="Financial or legal risk" if strpos(q19, "The first most important loss / risk / disadvantage from becoming suppliers to multinationals comes from the investment process. In most cases, they must invest to be able to face larger volume orders. However, non-fulfilling contracts given the established specifications implies the loss of the business, no matter how much the supplier has invested in the business.")>0
replace q19_stand="Financial or legal risk" if strpos(q19, "To be able to supply to multinationals, suppliers sometimes need to make large investments. These investments can turn out to be risky when there is not enough business to pay for these investments.")>0
replace q19_stand="Financial or legal risk" if strpos(q19, "The largest risk to the supplier is legal. If a supplier breaches a contract, they could face a lawsuit, which in turn reveals they’re uncapable to attend higher demands.")>0
replace q19_stand="Financial or legal risk" if strpos(q19, "The largest risk is financial. If the supplier makes a large investment for a specific deal with a multinational and the deal fall through, this can be a big hit for the supplier.")>0
replace q19_stand="Financial or legal risk" if strpos(q19, "The largest risk is financial. If the supplier makes a large investment for a specific deal with a multinational and the deal fall through, this can be a big hit for the supplier.")>0
replace q19_stand="Financial or legal risk" if strpos(q19, "The first most important loss / risk / disadvantage from becoming suppliers to multinationals is the ease with which they can lose a contract. The multinational operates by judging the quality and price it is offered. If suppliers are not consistent or if they do not operate under the agreed standards, the multinational will quickly change to another supplier.")>0
replace q19_stand="Financial or legal risk" if strpos(q19, "The first most important risk from becoming suppliers to multinationals is implicit in the business. For example, when the multinational produces a new variety of a product, as the multinational is itself a supplier to the medical cluster, this new variety is expected to have a certain level of acceptance in the market. In cases where this acceptance is not as expected and launching the product takes longer than expected, suppliers may suffer from payment delays, particularly if they are not large enough.")>0
replace q19_stand="Financial or legal risk" if strpos(q19, "The first most important loss / risk / disadvantage from becoming suppliers to multinationals comes from the lack of financial support. In Costa Rica, the existing opportunities to access credit do not create the adequate conditions to supply to multinationals. Costa Rican firms take a risk entering the ``big league” without enough [financial] support, this is the reason why they are on disadvantage from the start with respect to their competition.")>0
replace q19_stand="Financial or legal risk" if strpos(q19, "The first most important loss / risk / disadvantage from becoming suppliers to multinationals has to do with the little tolerance and flexibility from the multinationals side. If a supplier has already received the training provided by the multinational and, despite that, does not comply with the quality standards requested, they will be dismissed. Contracts between local suppliers and multinationals are very strict and if suppliers do not satisfy these contracts, that directly implies losing the business.")>0
replace q19_stand="Demanding changes" if strpos(q19, "Local firms need to leave their comfort zone and improve their business practices. For some managers, this transition is very unattractive.")>0
replace q19_stand="Demanding changes" if strpos(q19, "A disadvantage that occurs when working with the multinational is that the supplier has to deal with a lot of bureaucracy.")>0
replace q19_stand="Demanding changes" if strpos(q19, "The largest disadvantage/risk has to do with the level of pressure that a firm is put under when becoming a supplier to a multinational. Supplying to a multinational comes with many requirements, many specifications, high standards. Multinationals are very demanding. This can be very stressful for a small Costa Rican firm. Sometimes there are misunderstandings that come up due to misaligned expectations.")>0
replace q19_stand="Demanding changes" if strpos(q19, "This disadvantage applies for the new suppliers. The multinational can’t give the supplier a lot of time to adjust to the new requirements. The multinational has to respond to the market’s changing demands fast, which requires the suppliers to react fast as well; this, sometimes, troubles the suppliers.")>0
replace q19_stand="Demanding changes" if strpos(q19, "The first most important risk from becoming suppliers to multinationals is the burden of the new responsibilities acquired, to provide the specific product / service for which they were hired. Within multinational firms, there is a constant evolution and suppliers must maintain quality in an ever-changing business landscape.")>0
replace q19_stand="Demanding changes" if strpos(q19, "The first most important disadvantage of starting to work with multinationals has to do with their ``zero tolerance” policy of the multinationals. There is no forgiving of mistakes in the ``major league.” Once the business relationship was established, the supplier has little to no room for failure. Perhaps suppliers can have some failures at the very beginning, but very fast they need to succeed in delivering what they committed to. Multinationals cannot afford to be the sponsor of a supplier that is not up to the task forever and ever. They are willing to help but cannot be a charitable benefactor. Hence, suppliers to multinationals are under a lot of pressure to adapt fast, to change all their paradigms of how to do business, as to succeed in whatever they committed to supply.")>0
replace q19_stand="Demanding changes" if strpos(q19, "Desconocimiento de Normas de Calidad")>0
replace q19_stand="Bad reputation" if strpos(q19, "The first most important loss / risk / disadvantage from becoming suppliers to multinationals has to do with the possibility of earning a bad reputation. It is possible that, smaller suppliers to local suppliers to multinationals fail them and therefore the suppliers to the multinational fail the multinational. Failing to deliver to the multinational as expected is a sufficient reason not to be hired again.")>0
replace q19_stand="Specificity" if strpos(q19, "Given the market in which the multinational is, they need smaller volumes, which is  something that suppliers dislike.")>0
replace q19_stand="None" if q19=="" | q19=="NA" | q19=="No vemos que genere desventajas" | strpos(q19, "The multinational doesn’t see any disadvantage or risk that suppliers might suffer.")>0
}

display "Left panel of Table F19"
tabsort q19_stand

quiet {
gen q20_stand=""
replace q20_stand="Financial or legal risk" if strpos(q20, "A risk of the supplier is incurring is the loss associated to an expected sale not occurring. The supplier could lose the cost of the raw materials, if they don’t deliver on time, if the supplier fails to meet the agreed deadlines or if the supplier does a poor job in general.")>0
replace q20_stand="Financial or legal risk" if strpos(q20, "A disadvantage of this particular multinational is that it pays its suppliers in colones or in the local currency, so they suffer the consequences of dollar devaluations.")>0
replace q20_stand="Financial or legal risk" if strpos(q20, "Sometimes the deals include stipulations that are a disadvantage for the supplier, for example, the multinational works with really long payment deadlines.")>0
replace q20_stand="Financial or legal risk" if strpos(q20, "The second most important risk in becoming suppliers to multinationals are the fluctuations in the orders. Suppliers can face substantial changes in the quantity demanded and when they can’t keep up with new orders, they easily lose the contracts. Many local firms are not able to keep up with the multinational, particularly when the purchasing landscape changes up to 100%, suppliers are unable to adapt their production.")>0
replace q20_stand="Demanding changes" if strpos(q20, "A disadvantage is the tedious process the suppliers have to undergo in order to start working with the multinational (“the registering process”); it is a long and meticulous procedure, the multinational is very demanding. This occurs every time that the multinational has to make a decision about hiring a new supplier.")>0
replace q20_stand="Demanding changes" if strpos(q20, "The fast-paced nature of the market. The market changes fast, the competition is tough, and suppliers need to be agile in adapting to the new trends in the market.")>0
replace q20_stand="Demanding changes" if strpos(q20, "The second most important disadvantage/cost of starting to work with multinationals has to do with the fact that the same expectations, the same philosophy that suppliers adopt must also be passed on to their own suppliers as well, up the value chain. For example, the supplier might commit to a first deal given the inventory they already have but fail to adjust their inventory with their suppliers to future orders, that are for sure following the first. A long-term vision of collaboration with multinationals implies making changes not just in one’s firm but also in one’s suppliers.")>0
replace q20_stand="Demanding changes" if strpos(q20, "Capacidad de Respuesta")>0
replace q20_stand="Demanding changes" if strpos(q20, "A second related disadvantage has to do with the risk of failing to deliver consistently the product/service at the expected parameters. The product/service supplied is continuously assessed, they cannot miss the mark not even once. If they supplied all well once, in theory they have the technical ability to repeat that. But this consistency has to do with a managerial vision of excellence more than anything.")>0
replace q20_stand="Bad reputation" if strpos(q20, "Another risk to the supplier lies in revealing their capacity to the market. If the supplier fails, they show they are uncapable to conduct large businesses. This reflects deficiencies in its management, as a sign of lack of training.")>0
replace q20_stand="Bad reputation" if strpos(q20, "The second most important risk is reputational. Multinationals participate at seminars, at fora. They exchange on their experience with local suppliers. If a given relationship with a multinational goes sour, then this will become quickly known to other multinationals as well. For this reason, every commercial relationship matters for the reputation of a supplier, not to gain a reputation of being a bad supplier, from which it is hard to recover.")>0
replace q20_stand="Bad reputation" if strpos(q20, "The second most important loss / risk / disadvantage from becoming suppliers to multinationals is their reputation within the corporation and the industry. If they fail, they will in turn lose the trust of the market in which they have developed, and this will hinder future linkages. Recovering trust would require 10 times the effort they made at the beginning.")>0
replace q20_stand="Bad reputation" if strpos(q20, "The second most important risk in becoming suppliers to multinationals is entering the company’s “black list” if its trust, principles, or values are violated. It would mean not being considered for future deals. For the multinational, a violation of its trust is not complying with national laws.")>0
replace q20_stand="Specificity" if strpos(q20, "Given the market in which the multinational is, suppliers of direct inputs might feel too narrowly specialized.")>0
replace q20_stand="Other" if strpos(q20, "To some extent, the competitiveness of the business of certain suppliers depends on structural investments (e.g., in transportation infrastructure), which these suppliers cannot influence by themselves. Whether these structural investments occur or not greatly affects the ability of local suppliers to compete.")>0
replace q20_stand="Other" if strpos(q20, "The second most important loss / risk / disadvantage from becoming suppliers to multinationals is the strong competition within the industry. Multinationals often have core global suppliers that may be willing to follow them to other locations; this necessarily increases competition in the national market.")>0
replace q20_stand="None" if q20=="" | q20=="NA"
}

display "Middle panel of Table F19"
tabsort q20_stand

quiet {

gen q21_stand=""
replace q21_stand="Financial or legal risk" if strpos(q21, "The third largest disadvantage has to do with financing the necessary investments. Sometimes suppliers don’t have the right credit profile, that can ensure good funding conditions.")>0
replace q21_stand="Financial or legal risk" if strpos(q21, "Capital de Trabajo")>0
replace q21_stand="Demanding changes" if strpos(q21, "A disadvantage of working with the multinational is the high quality requirements it demands from its suppliers, in the product and in the service provided (meeting the deadlines). The supplier is at risk of losing the multinational as a client if it lowers the overall quality offered.")>0
replace q21_stand="Bad reputation" if strpos(q21, "If a relationship with one MNC does not end well, this can hurt the reputation of the supplier with all other MNCs. Suppliers need references from former MNC clients when trying to seal a new deal. MNCs have fora where they meet, MNCs are close geographically, employees move from one MNC to another, rumors travel fast. A deal gone wrong can have large implications for other potential deals.")>0
replace q21_stand="Other" if strpos(q21, "The third most important loss / risk / disadvantage from becoming suppliers to multinationals is the flight of qualified human capital towards the multinationals with whom they became linked. After the first contacts, their staff is trained within the industry they are joining. If they receive offers from the multinational, suppliers will most likely not be able to compete with those offers. Besides, the benefits of working for a multinational can hardly be compared with those offered by national firms.")>0
replace q21_stand="None" if q21=="" | q21=="NA"
}

display "Right panel of Table F19"
tabsort q21_stand

*********************************************************************************************************************************************
** Supplementary Table F20
** Questions 22 and 24 in the multinational firms survey (Questions 17 and 18 in the paper)
**********************************************************************************************************************************************

quiet {
use $answers_mnc , clear
keep q22 ID

gen exp=6
replace exp=1 if strpos(q22,"La mayoría de las decisiones sobre los insumos clave son tomadas por la casa matriz (u otro afiliado que no sea el afiliado en Costa Rica), con muy poca o ninguna retroalimentación sobre los proveedores costarricenses del afiliado costarricense.")>0
replace exp=1 if strpos(q22,"La mayoría de las decisiones sobre los insumos clave son tomadas por la sede (u otro afiliado que no sea el afiliado en Costa Rica), con muy poca o ninguna retroalimentación sobre los proveedores costarricenses del afiliado costarricense.")>0
replace exp=2 if strpos(q22,"La mayoría de las decisiones sobre los insumos clave son tomadas por la casa matriz (u otro afiliado que no sea el afiliado en Costa Rica), pero con comentarios sobre los proveedores costarricenses del afiliado costarricense.")>0
replace exp=2 if strpos(q22,"La mayoría de las decisiones sobre los insumos clave son tomadas por la sede (u otro afiliado que no sea el afiliado en Costa Rica), pero con comentarios sobre los proveedores costarricenses del afiliado costarricense.")>0
replace exp=3 if strpos(q22,"Las decisiones sobre los insumos clave se toman conjuntamente entre la casa matriz (u otra afiliada que no sea la afiliada en Costa Rica) y la filial costarricense.")>0
replace exp=3 if strpos(q22,"Las decisiones sobre los insumos clave se toman conjuntamente entre la sede (u otra afiliada que no sea la afiliada en Costa Rica) y la filial costarricense.")>0
replace exp=4 if strpos(q22,"La mayoría de las decisiones sobre los insumos clave son hechas por el afiliado costarricense, pero con los comentarios de la casa matriz (u otro afiliado que no sea el afiliado en Costa Rica")>0
replace exp=4 if strpos(q22,"La mayoría de las decisiones sobre los insumos clave son hechas por el afiliado costarricense, pero con los comentarios de la sede (u otro afiliado que no sea el afiliado en Costa Rica)")>0
replace exp=5 if strpos(q22,"La mayoría de las decisiones sobre los insumos clave son tomadas por el propio afiliado costarricense, con muy poca o ninguna retroalimentación de la casa matriz (u otro afiliado que no sea el afiliado en Costa Rica).")>0
replace exp=5 if strpos(q22,"La mayoría de las decisiones sobre los insumos clave son tomadas por el propio afiliado costarricense, con muy poca o ninguna retroalimentación de la sede (u otro afiliado que no sea el afiliado en Costa Rica).")>0
replace exp=3 if strpos(q22,"La mayoría de las decisiones sobre los insumos claves se toman en conjunto entre la operación local y la dirección regional que en nuestro caso atiende la región centroamérica.")>0
replace exp=1 if strpos(q22,"El grupo fija ciertos lineamientos que deben aplicarse en función del producto, si se considera necesario se abastece mediante venta intercompany. También puede procederse con distribuidores locales o regionales de marcas o especificaciones aprobadas por casa matriz.")>0

gen q22_comm=""
replace q22_comm="Corporate decides the specifications of inputs depending on the product. Corporate decides which local or regional firms are approved to supply to the local affiliate." if strpos(q22,"El grupo fija ciertos lineamientos que deben aplicarse en función del producto, si se considera necesario se abastece mediante venta intercompany. También puede procederse con distribuidores locales o regionales de marcas o especificaciones aprobadas por casa matriz.")>0
replace q22_comm="Most decisions are taken jointly between the local operation and the regional office." if strpos(q22,"La mayoría de las decisiones sobre los insumos claves se toman en conjunto entre la operación local y la dirección regional que en nuestro caso atiende la región centroamérica.")>0
replace q22_comm="The affiliate in Costa Rica does not use key inputs." if strpos(q22,"The affiliate in Costa Rica does not use key inputs.")>0
replace q22_comm="Decisions are made according to a determined budget. If expenses are under the budgeted amount, decisions are made locally; if they exceed the budget then the multinational has to contact the Procurement Department to aid in the process." if strpos(q22,"the decisions are made according to a determined budget. If the expenses are under the budget amount, the decisions are made locally; if they exceed the budget then the multinational has to contact the Procurement Department to aid in the process.")>0

gen     exp_lab="Other"
replace exp_lab="HQ, little local feedback" if exp==1
replace exp_lab="HQ, with local feedback" if exp==2
replace exp_lab="Joint decision" if exp==3
replace exp_lab="Local, with HQ feedback" if exp==4
replace exp_lab="Local, little HQ feedback" if exp==5
}

display "Left panel of Table 20"
quiet label var exp_lab "Core inputs"
tab exp_lab

quiet{
use $answers_mnc , clear
keep q24 ID

gen exp=6
replace exp=1 if strpos(q24,"La mayoría de las decisiones sobre los insumos secundarios son tomadas por la casa matriz (u otro afiliado que no sea el afiliado en Costa Rica), con muy poca o ninguna retroalimentación sobre los proveedores costarricenses del afiliado costarricense.")>0
replace exp=1 if strpos(q24,"La mayoría de las decisiones sobre los insumos secundarios son tomadas por la sede (u otro afiliado que no sea el afiliado en Costa Rica), con muy poca o ninguna retroalimentación sobre los proveedores costarricenses del afiliado costarricense.")>0
replace exp=2 if strpos(q24,"La mayoría de las decisiones sobre los insumos secundarios son tomadas por la casa matriz (u otro afiliado que no sea el afiliado en Costa Rica), pero con comentarios sobre los proveedores costarricenses del afiliado costarricense.")>0
replace exp=2 if strpos(q24,"La mayoría de las decisiones sobre los insumos secundarios son tomadas por la sede (u otro afiliado que no sea el afiliado en Costa Rica), pero con comentarios sobre los proveedores costarricenses del afiliado costarricense.")>0
replace exp=3 if strpos(q24,"Las decisiones sobre los insumos secundarios se toman conjuntamente entre la casa matriz (u otra afiliada que no sea la afiliada en Costa Rica) y la filial costarricense.")>0
replace exp=3 if strpos(q24,"Las decisiones sobre los insumos secundarios se toman conjuntamente entre la sede (u otra afiliada que no sea la afiliada en Costa Rica) y la filial costarricense.")>0
replace exp=4 if strpos(q24,"La mayoría de las decisiones sobre los insumos secundarios son hechas por el afiliado costarricense, pero con los comentarios de la casa matriz (u otro afiliado que no sea el afiliado en Costa Rica)")>0
replace exp=4 if strpos(q24,"La mayoría de las decisiones sobre los insumos secundarios son hechas por el afiliado costarricense, pero con los comentarios de la sede (u otro afiliado que no sea el afiliado en Costa Rica)")>0
replace exp=5 if strpos(q24,"La mayoría de las decisiones sobre los insumos secundarios  son tomadas por el propio afiliado costarricense, con muy poca o ninguna retroalimentación de la casa matriz (u otro afiliado que no sea el afiliado en Costa Rica).")>0
replace exp=5 if strpos(q24,"La mayoría de las decisiones sobre los insumos secundarios  son tomadas por el propio afiliado costarricense, con muy poca o ninguna retroalimentación de la sede (u otro afiliado que no sea el afiliado en Costa Rica).")>0
replace exp=5 if strpos(q24,"La mayoría de las decisiones sobre los insumos secundarios son tomadas por el propio afiliado costarricense, con muy poca o ninguna retroalimentación de la casa matriz (u otro afiliado que no sea el afiliado en Costa Rica).")>0
replace exp=5 if strpos(q24,"La mayoría de las decisiones sobre los insumos secundarios son tomadas por el propio afiliado costarricense, con muy poca o ninguna retroalimentación de la sede (u otro afiliado que no sea el afiliado en Costa Rica).")>0

gen q24_comm=""
replace q24_comm="Decisions are made according to a determined budget. If expenses are under the budgeted amount, decisions are made locally; if they exceed the budget then the multinational has to contact the Procurement Department to aid in the process." if strpos(q24,"The decisions are made according to a determined budget. If the expenses are under the budget amount, the decisions are made locally; if they exceed the budget then the multinational has to contact the Procurement Department to aid in the process.")>0

gen     exp_lab="Other"
replace exp_lab="HQ, little local feedback" if exp==1
replace exp_lab="HQ, with local feedback" if exp==2
replace exp_lab="Joint decision" if exp==3
replace exp_lab="Local, with HQ feedback" if exp==4
replace exp_lab="Local, little HQ feedback" if exp==5
}

display "Right panel of Table 20"
quiet label var exp_lab "Secondary inputs"
tab exp_lab



********************************************************************************
***************** ONLINE APPENDIX F: OTHER RESULTS *****************************
********************************************************************************

*****************************************************************************************************************
** Question 13 in the domestic firms survey corresponds to Online Appendix Question 6 in the paper
*****************************************************************************************************************

quiet{
use $answers_dom , clear
keep q13
gen q13_comm=""
gen q13final=""
replace q13f="NO" if q13==""
replace q13f="NO" if q13=="N/A"
replace q13f="NO" if q13=="NO"
replace q13f="NO" if q13=="No"
replace q13f="NO" if q13=="No change, no."
replace q13f="NO" if q13=="No, no change."
replace q13f="NO" if q13=="no"
replace q13f="NO" if q13=="No, there was no sudden change."
replace q13f="NO" if strpos(q13,"Yes, the structure of the operation had to be adjusted in order to meet the quality standards and supply the demand. Likewise, it was possible to upgrade the position of the firm at the regional level and then achieved the internationalization.")
replace q13_comm="Yes, the structure of the operation had to be adjusted in order to meet the quality standards and supply the demand. Likewise, it was possible to upgrade the position of the firm at the regional level and then achieved the internationalization." if strpos(q13,"Yes, the structure of the operation had to be adjusted in order to meet the quality standards and supply the demand. Likewise, it was possible to upgrade the position of the firm at the regional level and then achieved the internationalization.")
replace q13f="NO" if strpos(q13,"Yes, the local firm had to change its productive capacity to be able to supply its clients more quickly.")
replace q13_comm="Yes, the local firm had to change its productive capacity to be able to supply its clients more quickly." if strpos(q13,"Yes, the local firm had to change its productive capacity to be able to supply its clients more quickly.")
replace q13f="YES" if strpos(q13,"Yes. The opening of the Schneider Electric's plant in Costa Rica represented a business opportunity for the local firm, it was born when they became a supplier of this multinational.")
replace q13_comm="Yes. The opening of the Schneider Electric's plant in Costa Rica represented a business opportunity for the local firm, it was born when they became a supplier of this multinational." if strpos(q13,"Yes. The opening of the Schneider Electric's plant in Costa Rica represented a business opportunity for the local firm, it was born when they became a supplier of this multinational.")
replace q13f="YES" if strpos(q13,"Yes, the implementation of the ISO 9001:2015 certification.")
replace q13_comm="Yes, the implementation of the ISO 9001:2015 certification." if strpos(q13,"Yes, the implementation of the ISO 9001:2015 certification.")
replace q13f="YES" if strpos(q13,"Yes, the local firm focused its efforts towards a particular industry, the medical.")
replace q13_comm="Yes, the local firm focused its efforts towards a particular industry, the medical." if strpos(q13,"Yes, the local firm focused its efforts towards a particular industry, the medical.")
replace q13f="YES" if strpos(q13,"Yes, the local firm started advertising its products through a novel website and placed ads of the company in the main search engines.")
replace q13_comm="Yes, the local firm started advertising its products through a novel website and placed ads of the company in the main search engines." if strpos(q13,"Yes, the local firm started advertising its products through a novel website and placed ads of the company in the main search engines.")
replace q13f="YES" if strpos(q13,"Yes, the local firm hired specialized labor force.")
replace q13_comm="Yes, the local firm hired specialized labor force." if strpos(q13,"Yes, the local firm hired specialized labor force.")
replace q13f="NO" if strpos(q13,"Yes, previously the local firm had several consolidated lines of its products. The firm went out to look for new products and markets and at that moment they started negotiations with multinational clients.")
replace q13_comm="Yes, previously the local firm had several consolidated lines of its products. The firm went out to look for new products and markets and at that moment they started negotiations with multinational clients." if strpos(q13,"Yes, previously the local firm had several consolidated lines of its products. The firm went out to look for new products and markets and at that moment they started negotiations with multinational clientt")
replace q13f="YES"  if strpos(q13,"Si; profesionalización del servicio a través de capacitaciones e información")>0
replace q13_comm="Yes. The firm improved the quality of the service through training." if strpos(q13,"Si; profesionalización del servicio a través de capacitaciones e información")>0 

drop q13
ren q13f q13
}

display "Online Appendix Question 6"
tabsort q13

*****************************************************************************************************************
** Question 15 in the domestic firms survey was not discussed in the paper
*****************************************************************************************************************

quiet{
use $answers_dom , clear
keep ID q15

gen exp=7
replace exp=1 if strpos(q15,"En menos de 1 mes")>0
replace exp=2 if strpos(q15,"Tomó entre 1 mes y 6 meses")>0
replace exp=3 if strpos(q15,"Tomó entre 6 meses y 1 año")>0
replace exp=4 if strpos(q15,"Tomó más de 1 año, pero menos de 2 años")>0
replace exp=5 if strpos(q15,"Tomó más de 2 años")>0
replace exp=6 if strpos(q15,"La pregunta no se aplica: la firma no buscó explícitamente clientes multinacionales, las multinacionales encontraron nuestra firma")>0

gen q15_comm=""
replace q15_comm="Eversince its creation, the commercial focus of the firm was to supply to MNCs." if strpos(q15,"La empresa desde su nacimiento enfoco su modelo comercial hacia suplir a empresas multinacionales")>0
replace q15_comm="The firm was born out of a necessity of an MNC." if strpos(q15,"La empresa se creo por la necesidad que presentaba la multinacional.")>0
replace q15_comm="The firm was created to supply to a specific (newly-entered) MNC." if strpos(q15,"Nuestra empresa nació con la oportunidad de proveer a Schneider Electric")>0
replace q15_comm="It was a mutual reaching out." if strpos(q15,"De las dos formas")>0 
replace q15_comm="We were not expecting having MNC clients." if strpos(q15,"No esperamos tener clientes de multinacionales")>0

replace exp=6 if strpos(q15_comm,"We were not expecting having MNC clients.")>0
replace exp=2 if strpos(q15_comm,"Eversince its creation, the commercial focus of the firm was to supply to MNCs")>0 
replace exp=2 if strpos(q15_comm,"The firm was born out of a necessity of an MNC")>0 
replace exp=2 if strpos(q15_comm,"The firm was created to supply to a specific (newly-entered) MNC")>0 

gen exp_lab="Other"
replace exp_lab="< 1 month" if exp==1
replace exp_lab="1-6 months" if exp==2
replace exp_lab="6-12 months" if exp==3
replace exp_lab="1-2 years" if exp==4
replace exp_lab=">2 years" if exp==5
replace exp_lab="MNC contacted firm" if exp==6
}

*****************************************************************************************************************
** Question 21 in the domestic firms survey corresponds to Online Appendix Question 12  in the paper
** This was an open-ended question. In the paper, we presented some examples of answers.
*****************************************************************************************************************

quiet{
use $answers_dom , clear
keep q21
} 


*****************************************************************************************************************
** Questions 23 and 24 in the domestic firms survey correspond to Online Appendix Question 14  in the paper.
** These were open-ended questions asked in the long survey. In the paper, we presented some examples of answers.
*****************************************************************************************************************

quiet{
use $answers_dom , clear
keep ID q23 q24
}

******************************************************************************************************************************
** Questions 30, 31 and 34 in the domestic firms survey were not discussed in the paper
******************************************************************************************************************************

quiet{
use $answers_dom , clear
keep q30 q31 ID

gen     q302="YES. Export performance improved."
replace q302="NO. No improvement in export performance." if q30=="NO, no mejoró nuestro desempeño de exportación."
drop q30
ren  q302 q30

drop if q30=="NO. No improvement in export performance."

gen t31_1=strpos(q31,"La mayor parte de nuestra mejora en el desempeño de exportación proviene de la exportación a afiliados")>0
gen q31_1=(t31_1!=0)
drop t31_1

gen t31_2=strpos(q31,"Hemos aprendido de clientes multinacionales en Costa Rica sobre la demanda o los gustos extranjeros")>0
gen q31_2=(t31_2!=0)
drop t31_2

gen t31_3=strpos(q31,"Hemos aprendido de clientes multinacionales en Costa Rica sobre prácticas comerciales extranjeras")>0
gen q31_3=(t31_3!=0)
drop t31_3

gen t31_4=strpos(q31,"Nos hemos vuelto más eficientes después de convertirnos en proveedores de multinacionales en Costa Rica")>0
gen q31_4=(t31_4!=0)
drop t31_4

gen t31_5=strpos(q31,"Hemos mejorado la calidad de nuestros productos o servicios, lo que nos ha permitido proponer productos o servicios más atractivos para nuestros clientes en el exterior")>0
gen q31_5=(t31_5!=0)
drop t31_5

gen q31_6=q31
replace q31_6=subinstr(q31_6,"La mayor parte de nuestra mejora en el desempeño de exportación proviene de la exportación a afiliados en otros países de los mismos clientes multinacionales en Costa Rica", "",.)
replace q31_6=subinstr(q31_6,"Hemos aprendido de clientes multinacionales en Costa Rica sobre la demanda o los gustos extranjeros, lo que nos ha permitido proponer productos o servicios más atractivos a clientes en el extranjero", "",.)
replace q31_6=subinstr(q31_6,"Hemos aprendido de clientes multinacionales en Costa Rica sobre prácticas comerciales extranjeras (por ejemplo, prácticas de comunicación), lo que nos ha permitido acercarnos mejor a nuestros clientes en el extranjero", "",.)
replace q31_6=subinstr(q31_6,"Nos hemos vuelto más eficientes después de convertirnos en proveedores de multinacionales en Costa Rica, por lo tanto, podemos ofrecer precios más bajos a clientes extranjeros", "",.)
replace q31_6=subinstr(q31_6,"Hemos mejorado la calidad de nuestros productos o servicios, lo que nos ha permitido proponer productos o servicios más atractivos para nuestros clientes en el exterior", "",.)
replace q31_6=subinstr(q31_6,",", "",.)
replace q31_6=subinstr(q31_6,"`""'", "",.)
replace q31_6=subinstr(q31_6,".", "",.)
replace q31_6=subinstr(q31_6,"|", "",.)

gen q31_62=q31_6
replace q31_62=subinstr(q31_62," ", "",.)
gen q31_6f=(q31_62!="")
replace q31_6=q31_62 if q31_62==""
ren q31_6  q31_comm
ren q31_6f q31_6
drop q31_62

replace q31_2=1 if q31_comm=="the local firm has increased its range of suppliers which allows it to offer innovative products to satisfy new necessities"
replace q31_6=0 if strpos(q31_comm,"the local firm has increased its range of suppliers which allows it to offer innovative products to satisfy new necessities")>0
replace q31_comm="The local firm has increased its range of suppliers which allows it to offer innovative products to satisfy new necessities"  if q31_comm=="the local firm has increased its range of suppliers which allows it to offer innovative products to satisfy new necessities"

replace q31_5=1      if q31_comm=="Hemos podido brindar mejores servicios"
replace q31_6=0      if q31_comm=="Hemos podido brindar mejores servicios"
replace q31_comm=""  if q31_comm=="Hemos podido brindar mejores servicios"

forval i=1/6 {
egen sh31_`i'= mean(q31_`i')
replace sh31_`i'= sh31_`i'*100
}

quietly bys sh31_1:  gen dup = cond(_N==1,0,_n)
drop if dup>1

keep sh31* ID
reshape long sh31_, i(ID) j(exp)

drop ID
ren sh31_ Percentage
replace Percentage=round(Percentage, 0.1)

gen     exp_lab="Other"
replace exp_lab="Most gains came from w/n MNC" if exp==1
replace exp_lab="Learnt on foreign demand/tastes" if exp==2
replace exp_lab="Learnt on commercial practices"  if exp==3
replace exp_lab="Became more efficient, lower prices" if exp==4
replace exp_lab="Improved quality" if exp==5

use $answers_dom , clear
keep q30 q34 ID

gen     q302="YES. Export performance improved."
replace q302="NO. No improvement in export performance." if q30=="NO, no mejoró nuestro desempeño de exportación."
drop q30
ren  q302 q30
drop if q30=="YES. Export performance improved."

gen t34_1=strpos(q34,"Lo que la empresa produce no se puede exportar, por lo tanto, esta pregunta no se aplica a la empresa")>0
gen q34_1=(t34_1!=0)
drop t34_1
gen t34_2=strpos(q34,"La empresa no está interesada en exportar. Por lo tanto, la empresa no ha hecho ningún esfuerzo para mejorar su desempeño de exportación")>0
gen q34_2=(t34_2!=0)
drop t34_2
gen t34_3=strpos(q34,"La empresa está interesada en exportar, pero ha estado demasiado ocupada sirviendo a las multinacionales en Costa Rica")>0
gen q34_3=(t34_3!=0)
drop t34_3
gen t34_4=strpos(q34,"La empresa está interesada en exportar y podría haber exportado ya que había capacidad productiva para manejar tanto el negocio en Costa Rica como en el extranjero. Sin embargo, la empresa aún no puede encontrar clientes en el exterior")>0
gen q34_4=(t34_4!=0)
drop t34_4
gen t34_5=strpos(q34,"La empresa está interesada en exportar y podría haber exportado ya que había capacidad productiva para manejar tanto el negocio en Costa Rica como en el extranjero. Sin embargo, la empresa aún no puede ofrecer precios competitivos a clientes en el extranjero")>0
gen q34_5=(t34_5!=0)
drop t34_5

gen     q34_comm=q34
replace q34_comm=subinstr(q34_comm,"Lo que la empresa produce no se puede exportar, por lo tanto, esta pregunta no se aplica a la empresa", "",.)
replace q34_comm=subinstr(q34_comm,"La empresa no está interesada en exportar. Por lo tanto, la empresa no ha hecho ningún esfuerzo para mejorar su desempeño de exportación", "",.)
replace q34_comm=subinstr(q34_comm,"La empresa está interesada en exportar, pero ha estado demasiado ocupada sirviendo a las multinacionales en Costa Rica", "",.)
replace q34_comm=subinstr(q34_comm,"La empresa está interesada en exportar y podría haber exportado ya que había capacidad productiva para manejar tanto el negocio en Costa Rica como en el extranjero. Sin embargo, la empresa aún no puede encontrar clientes en el exterior", "",.)
replace q34_comm=subinstr(q34_comm,"La empresa está interesada en exportar y podría haber exportado ya que había capacidad productiva para manejar tanto el negocio en Costa Rica como en el extranjero. Sin embargo, la empresa aún no puede ofrecer precios competitivos a clientes en el extranjero", "",.)
replace q34_comm=subinstr(q34_comm,",", "",.)
replace q34_comm=subinstr(q34_comm,"`""'", "",.)
replace q34_comm=subinstr(q34_comm,".", "",.)
replace q34_comm=subinstr(q34_comm,"|", "",.)

gen q34_6=0
gen q34_commtemp=q34_comm
replace q34_commtemp=subinstr(q34_commtemp," ", "",.)
replace q34_comm=q34_commtemp if q34_commtemp==""
replace q34_3=1     if q34_comm=="El objetivo es llegar a exportar"
replace q34_comm="" if strpos(q34_comm,"El objetivo es llegar a exportar")>0

replace q34_comm="What the firm knows about exporting wasn’t learned from working with multinationals because it exports different kinds of products from the ones that are sold to the multinationals" if strpos(q34_comm,"34")>0
replace q34_6=1 if q34_comm=="What the firm knows about exporting wasn’t learned from working with multinationals because it exports different kinds of products from the ones that are sold to the multinationals"

replace q34_1=1     if q34_comm=="No exportamos"
replace q34_comm="" if strpos(q34_comm,"No exportamos")>0 
replace q34_1=1     if q34_comm=="No somos exportadores Porveemos servicios"
replace q34_comm="" if strpos(q34_comm,"No somos exportadores Porveemos servicios")>0

replace q34_4=1     if q34_comm=="LA EMPRESA NO CUENTA CON LA CAPACIDAD PRODUCTIVA PARA EXPORTAR A MAYORISTAS Y NO SE HAN OBTENIDO CONTACTOS PARA VENTAS A CLIENTES DIRECTOS"
replace q34_comm="" if strpos(q34_comm,"LA EMPRESA NO CUENTA CON LA CAPACIDAD PRODUCTIVA PARA EXPORTAR A MAYORISTAS Y NO SE HAN OBTENIDO CONTACTOS PARA VENTAS A CLIENTES DIRECTOS")>0

replace q34_6=1 if q34_comm=="The supplier doesn’t export products because it has a regional character If a product is needed abroad it’s sent to one of the supplier’s affiliates which then makes the sale"
replace q34_comm="" if strpos(q34_comm,"Nuestro servicio lo exportamos pero como medida de expansion")>0
replace q34_2=1     if q34_comm=="la empresa no tienes aspiraciones como exportadora a corto plazo Se realiza si es necesario pero más que una cuestión de iniciativa sucede cuando el cliente no contacta para realizar la compra Nuestro interés es ganar mercado nacional"
replace q34_comm="" if strpos(q34_comm,"la empresa no tienes aspiraciones como exportadora a corto plazo Se realiza si es necesario pero más que una cuestión de iniciativa sucede cuando el cliente no contacta para realizar la compra Nuestro interés es ganar mercado nacional")>0

drop q34_commtemp
forval i=1/6 {
egen sh34_`i'= mean(q34_`i')
replace sh34_`i'= sh34_`i'*100
}

quietly bys sh34_1:  gen dup = cond(_N==1,0,_n)
drop if dup>1

keep sh34* ID
reshape long sh34_, i(ID) j(exp)

drop ID
ren sh34_ Percentage
replace Percentage=round(Percentage, 0.1)

gen     exp_lab="Other"
replace exp_lab="Service / cannot be exported" if exp==1
replace exp_lab="Not interested to export" if exp==2
replace exp_lab="Interested, but too busy locally"  if exp==3
replace exp_lab="Interested, but cannot find clients" if exp==4
replace exp_lab="Interested, but not competitive yet" if exp==5
}


*****************************************************************************************************************
** Question 37 in the domestic firms survey corresponds to Online Appendix Question 21  in the paper.
** These were open-ended questions asked in the long survey. In the paper, we presented some examples of answers.
*****************************************************************************************************************

quiet{
use $answers_dom , clear
keep ID q37
drop if q37==""
}

*****************************************************************************************************************
** Question 38 in the domestic firms survey corresponds to Online Appendix Question 22  in the paper.
** These were open-ended questions asked in the long survey. In the paper, we presented some examples of answers.
*****************************************************************************************************************

quiet{
use $answers_dom , clear
keep ID q38
drop if q38==""
}



log close
translate `logfile'.smcl `logfile'.txt , replace linesize(250)
erase `logfile'.smcl
